This repository has been archived by the owner on Mar 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gg2stats.py
9863 lines (9160 loc) · 355 KB
/
gg2stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
import os
import webapp2
import logging
import datetime
import json
from google.appengine.ext import ndb
from google.appengine.api import users
from google.appengine.api import mail
from google.appengine.api import images
from google.appengine.api import memcache
from google.appengine.datastore.datastore_query import Cursor
from random import randint
from random import choice
#NOT version of website!
#This is a version of plug-in
version = 'v1.5.0'
#현재 시즌
GG2S_CURRENT_SEASON = 4
_CLASSES = ["Runner", "Firebug", "Rocketman", "Overweight", "Detonator", "Healer", "Constructor", "Infiltrator", "Rifleman", "Quote"]
BAN_LIST = ["httpslashoff",
"olivertosic21",
"momongki123",
"saiyu915"]
#일퀘, index=퀘스트 타입, 0: 퀘스트 이름, 1:퀘스트 설명, 2: 퀘스트 목표 카운트, 3: 퀘스트 보상액, 4: 퀘스트 종류(포괄), 5: 퀘스트 종류(세부)
#4: OVERALL_STAT, OVERALL_PLAYTIME, CLASS_KILL, CLASS_DEATH, CLASS_ASSIST, CLASS_PLAYTIME, WIN_TYPE
#5:
#OVERALL_STAT
#[0: KILL, 1: DEATH, 2: ASSIST, 3: CAP, 4: DESTORY, 5: STAB, 6: HEAL, 7:DEFENSE, 8: INVULN]
#OVERALL_PLAYTIME
#[0: TOTAL, 1: TEAM_RED, 2: TEAM_BLUE, 3: TEAM_SPECTATOR]
#CLASS_ORDER
#[0: SCOUT, 1: SOLDIER, 2: SNIPER, 3:DEMOMAN, 4: MEDIC, 5: ENGINEER, 6: HEAVY, 7: SPY, 8: PYRO, 9: QUOTE]
#WIN_TYPE
#[0: WIN, 1: LOSE, 2: STALEMATE, 3: DISCONNECT]
_QUESTS = [["Domination", "Kill 50 enemies", 50, 30, 0, 0],
["Hua Tuo", "Heal 10000 points", 10000, 30, 0, 6],
["Charge!", 'Kill 30 enemies with Firebug or Quote', 30, 30, 2, [8, 9]],
["WHAAM!", 'Kill 30 enemies with Rocketman or Detonator', 30, 30, 2, [1, 3]],
["Bad Company", 'Kill 30 enemies with Infiltrator or Rifleman', 30, 30, 2, [7, 2]],
["Stay Close", 'Kill 30 enemies with Firebug or Overweight', 30, 30, 2, [8, 6]],
["Happy Camping", 'Kill 30 enemies with Constructor or Rifleman', 30, 30, 2, [5, 2]],
["Intel Carriers", 'Kill 30 enemies with Runner or Infiltrator', 30, 30, 2, [0, 7]],
["Creator, Destroyer", 'Kill 30 enemies with Detonator or Constructor', 30, 30, 2, [3, 5]],
["Giant & Tiny", 'Kill 30 enemies with Overweight or Quote', 30, 30, 2, [6, 9]],
["Airbornes", 'Kill 30 enemies with Runner or Rocketman', 30, 30, 2, [0, 1]],
["Runner Beginner", "Play 15 minutes as Runner", 27000, 40, 5, 0],
["Firebug Beginner", "Play 15 minutes as Firebug", 27000, 40, 5, 8],
["Rocketman Beginner", "Play 15 minutes as Rocketman", 27000, 40, 5, 1],
["Overweight Beginner", "Play 15 minutes as Overweight", 27000, 40, 5, 6],
["Detonator Beginner", "Play 15 minutes as Detonator", 27000, 40, 5, 3],
["Healer Beginner", "Play 15 minutes as Healer", 27000, 40, 5, 4],
["Constructor Beginner", "Play 15 minutes as Constructor", 27000, 40, 5, 5],
["Infiltrator Beginner", "Play 15 minutes as Infiltrator", 27000, 40, 5, 7],
["Rifleman Beginner", "Play 15 minutes as Rifleman", 27000, 40, 5, 2],
["Quote Beginner", "Play 15 minutes as Quote", 27000, 40, 5, 9],
["!", "Kill 10 enemies with Backstab", 10, 30, 0, 5],
["Bullefproof!", "Use invuln 5 times", 5, 30, 0, 8],
["3 Victories!", "Win 3 games", 3, 30, 6, 0],
["His crop, My points", 'Destroy 5 autoguns', 5, 30, 0, 4],
["Runner Master", "Play 30 minutes as Runner", 54000, 60, 5, 0],
["Firebug Master", "Play 30 minutes as Firebug", 54000, 60, 5, 8],
["Rocketman Master", "Play 30 minutes as Rocketman", 54000, 60, 5, 1],
["Overweight Master", "Play 30 minutes as Overweight", 54000, 60, 5, 6],
["Detonator Master", "Play 30 minutes as Detonator", 54000, 60, 5, 3],
["Healer Master", "Play 30 minutes as Healer", 54000, 60, 5, 4],
["Constructor Master", "Play 30 minutes as Constructor", 54000, 60, 5, 5],
["Infiltrator Master", "Play 30 minutes as Infiltrator", 54000, 60, 5, 7],
["Rifleman Master", "Play 30 minutes as Rifleman", 54000, 60, 5, 2],
["Quote Master", "Play 30 minutes as Quote", 54000, 60, 5, 9],
["Garrison Gang", "Play for 3 hours", 324000, 100, 1, 0]
]
#User property class
class UserEntity(ndb.Model):
user_id = ndb.StringProperty()
user_clan = ndb.StringProperty(default='', indexed=False)
user_word = ndb.StringProperty(default='', indexed=False)
user_favclass = ndb.StringProperty(default='Runner')
user_region = ndb.StringProperty(default='', indexed=False)
user_message = ndb.StringProperty(default='Hi', indexed=False)
user_title = ndb.StringProperty(default='', indexed=False)
user_avatar = ndb.BlobProperty(indexed=False)
user_coin = ndb.IntegerProperty(default=0, indexed=False)
user_level = ndb.IntegerProperty(default=1)
user_exp = ndb.IntegerProperty(default=0, indexed=False)
google_id = ndb.UserProperty()
#User's Stat Entity
class UserStatEntity(ndb.Model):
user_point = ndb.IntegerProperty(default=1000)
user_kill = ndb.IntegerProperty(default=0)
user_death = ndb.IntegerProperty(default=0)
user_assist = ndb.IntegerProperty(default=0)
user_cap = ndb.IntegerProperty(default=0, indexed=False)
user_destruction = ndb.IntegerProperty(default=0, indexed=False)
user_stab = ndb.IntegerProperty(default=0, indexed=False)
user_healing = ndb.FloatProperty(default=0.0, indexed=False)
user_defense = ndb.IntegerProperty(default=0, indexed=False)
user_invuln = ndb.IntegerProperty(default=0, indexed=False)
user_kda = ndb.FloatProperty(default=0.0)
user_playcount = ndb.IntegerProperty(default=0)
user_playtime = ndb.IntegerProperty(default=0)
user_redtime = ndb.IntegerProperty(default=0, indexed=False)
user_bluetime = ndb.IntegerProperty(default=0, indexed=False)
user_spectime = ndb.IntegerProperty(default=0, indexed=False)
user_win = ndb.IntegerProperty(default=0, indexed=False)
user_lose = ndb.IntegerProperty(default=0, indexed=False)
user_stalemate = ndb.IntegerProperty(default=0, indexed=False)
user_escape = ndb.IntegerProperty(default=0, indexed=False)
#Season Stat Entity
class SeasonStatEntity(ndb.Model):
season = ndb.IntegerProperty()
season_owner = ndb.IntegerProperty()
user_point = ndb.IntegerProperty(default=1000)
user_kill = ndb.IntegerProperty(default=0)
user_death = ndb.IntegerProperty(default=0)
user_assist = ndb.IntegerProperty(default=0)
user_cap = ndb.IntegerProperty(default=0, indexed=False)
user_destruction = ndb.IntegerProperty(default=0, indexed=False)
user_stab = ndb.IntegerProperty(default=0, indexed=False)
user_healing = ndb.FloatProperty(default=0.0, indexed=False)
user_defense = ndb.IntegerProperty(default=0, indexed=False)
user_invuln = ndb.IntegerProperty(default=0, indexed=False)
user_kda = ndb.FloatProperty(default=0.0)
user_playcount = ndb.IntegerProperty(default=0)
user_playtime = ndb.IntegerProperty(default=0)
user_redtime = ndb.IntegerProperty(default=0, indexed=False)
user_bluetime = ndb.IntegerProperty(default=0, indexed=False)
user_spectime = ndb.IntegerProperty(default=0, indexed=False)
user_win = ndb.IntegerProperty(default=0, indexed=False)
user_lose = ndb.IntegerProperty(default=0, indexed=False)
user_stalemate = ndb.IntegerProperty(default=0, indexed=False)
user_escape = ndb.IntegerProperty(default=0, indexed=False)
class_kill = ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
class_death = ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
class_assist = ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
class_playtime = ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
#Today's user property class
class TodayEntity(ndb.Model):
user_kill = ndb.IntegerProperty(default=0, indexed=False)
user_death = ndb.IntegerProperty(default=0, indexed=False)
user_assist = ndb.IntegerProperty(default=0, indexed=False)
user_cap = ndb.IntegerProperty(default=0, indexed=False)
user_destruction = ndb.IntegerProperty(default=0, indexed=False)
user_stab = ndb.IntegerProperty(default=0, indexed=False)
user_healing = ndb.FloatProperty(default=0.0, indexed=False)
user_defense = ndb.IntegerProperty(default=0, indexed=False)
user_invuln = ndb.IntegerProperty(default=0, indexed=False)
user_kda = ndb.FloatProperty(default=0.0, indexed=False)
user_playcount = ndb.IntegerProperty(default=0, indexed=False)
user_point = ndb.IntegerProperty(default=0)
#각 병과별 스탯 통합 Entity
class ClassEntity(ndb.Model):
kill = ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
death=ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
assist=ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
playtime=ndb.StringProperty(default='0,0,0,0,0,0,0,0,0,0', indexed=False)
#짧은 로그용 스탯 엔티티
class MatchEntity(ndb.Model):
match_result = ndb.IntegerProperty(indexed=False)
match_kill = ndb.IntegerProperty(default=0, indexed=False)
match_death = ndb.IntegerProperty(default=0, indexed=False)
match_assist = ndb.IntegerProperty(default=0, indexed=False)
match_playtime = ndb.IntegerProperty(default=0, indexed=False)
match_server = ndb.StringProperty(default='', indexed=False)
match_mode = ndb.StringProperty(default='', indexed=False)
match_map = ndb.StringProperty(default='', indexed=False)
match_datetime = ndb.DateTimeProperty(auto_now_add=True)
match_redteam = ndb.StringProperty(default='', indexed=False)
match_blueteam = ndb.StringProperty(default='', indexed=False)
match_myself = ndb.IntegerProperty(default=-1, indexed=False)
match_score = ndb.StringProperty(default='', indexed=False) #레드:블루 성적
match_owner = ndb.IntegerProperty()
#아이템 정보 참조용 DB Entity, 아이템의 이름이 Key
class ItemEntity(ndb.Model):
item_nickname = ndb.StringProperty(indexed=False)
item_author = ndb.StringProperty(indexed=False)
item_desc = ndb.StringProperty(default='', indexed=False)
item_part = ndb.IntegerProperty()
item_classlist = ndb.StringProperty(indexed=False) #리스트를 스트링의 형태로 형변환
can_get = ndb.BooleanProperty(default=True)
is_vintage = ndb.BooleanProperty(default=False)
#실제 플레이어의 백팩 정보
class BackpackEntity(ndb.Model):
item_name = ndb.StringProperty(indexed=False) #ItemEntity Key 참조용
item_owner = ndb.IntegerProperty()
item_rarity = ndb.IntegerProperty(default=0, indexed=False) #아이템의 레어도 0 = normal, 1 = strange, 2 = unusual...
item_part = ndb.IntegerProperty()
item_effect = ndb.IntegerProperty(indexed=False)
item_strangeType = ndb.IntegerProperty(indexed=False)
item_strangeCount = ndb.IntegerProperty(default=0, indexed=False)
item_level = ndb.IntegerProperty(default=1, indexed=False)
item_getdate = ndb.DateTimeProperty(auto_now_add=True)
is_trading = ndb.BooleanProperty(default=False, indexed=False)
#플레이어의 로드아웃 정보 저장
class LoadoutEntity(ndb.Model):
head_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
torso_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
leg_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
weapon_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
misc_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
taunt_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
pet_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
death_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
humiliation_list = ndb.StringProperty(default=',,,,,,,,,', indexed=False)
class DailyquestEntity(ndb.Model):
quest_owner = ndb.IntegerProperty()
quest_type = ndb.IntegerProperty(indexed=False)
quest_count = ndb.IntegerProperty(default=0, indexed=False)
class TrophyEntity(ndb.Model):
trophy_owner = ndb.IntegerProperty()
trophy_index = ndb.IntegerProperty(indexed=False)
trophy_getdate = ndb.DateTimeProperty(auto_now_add=True)
#거래(만드는 쪽)
class TradeEntity(ndb.Model):
trade_item = ndb.IntegerProperty(indexed=False)
trade_coin = ndb.IntegerProperty()
trade_itemname = ndb.StringProperty() #아이템 이름
trade_enddate = ndb.DateProperty()
trade_owner = ndb.UserProperty()
#거래(제안하는 쪽)
class OfferEntity(ndb.Model):
offer_owner = ndb.UserProperty()
offer_target = ndb.IntegerProperty()
offer_item = ndb.StringProperty(indexed=False)
offer_targetuser = ndb.UserProperty()
#각종 로그 기록, 메인 페이지에 표시
class LogEntity(ndb.Model):
log_owner = ndb.UserProperty()
log_content = ndb.StringProperty(indexed=False)
log_date = ndb.DateTimeProperty(auto_now_add=True)
log_checked = ndb.BooleanProperty(default=False)
#프로필 페이지 댓글
class ReplyEntity(ndb.Model):
reply_owner = ndb.UserProperty()
reply_target = ndb.UserProperty()
reply_content = ndb.StringProperty(indexed=False)
reply_date = ndb.DateTimeProperty(auto_now_add=True)
reply_checked = ndb.BooleanProperty(default=False)
#게시판 글
class ArticleEntity(ndb.Model):
article_owner = ndb.KeyProperty()
article_title = ndb.StringProperty(indexed=False)
article_content = ndb.StringProperty(indexed=False)
article_date = ndb.DateTimeProperty(auto_now_add=True)
article_type = ndb.IntegerProperty(indexed=False)
article_replycnt = ndb.IntegerProperty(default=0, indexed=False)
#게시판 댓글
class ArticleReplyEntity(ndb.Model):
reply_owner = ndb.KeyProperty()
reply_target = ndb.KeyProperty()
reply_content = ndb.StringProperty(indexed=False)
reply_date = ndb.DateTimeProperty(auto_now_add=True)
#삭제된 댓글 저장용
class DeletedArticleReplyEntity(ndb.Model):
reply_owner = ndb.KeyProperty()
reply_target = ndb.KeyProperty()
reply_content = ndb.StringProperty(indexed=False)
reply_date = ndb.DateTimeProperty(auto_now_add=True)
#Clan의 이미지가 있을 시 클랜의 이미지 주소를, 없을시 빈 스트링을 반환하는 함수
def findClanImage(clan_str):
if clan_str.lower() == '[hark]' or clan_str.lower() == 'hark':
found_image = '/clan/clan_hark.gif'
elif clan_str.lower() == '[knu]' or clan_str.lower() == 'knu':
found_image = '/clan/clan_knu.gif'
elif clan_str.lower() == '[k:nu]' or clan_str.lower() == 'k:nu':
found_image = '/clan/clan_k_nu.gif'
elif clan_str.lower() == '[ivalice]' or clan_str.lower() == 'ivalice':
found_image = '/clan/clan_ivalice.gif'
elif clan_str.lower() == '[darkwhispr]' or clan_str.lower() == 'darkwhispr':
found_image = '/clan/clan_darkwhispr.gif'
elif clan_str.lower() == '[pyromania]' or clan_str.lower() == 'pyromania':
found_image = '/clan/clan_pyromania.gif'
else:
found_image = ''
return found_image
#주어진 String에 따라 해당하는 클래스의 이미지 주소를 반환하는 함수, 해당값이 없을 시 빈 스트링을 반환
def findClassImage(class_string, team=0):
if (team==0):
if class_string == 'Runner':
class_image = '/images/class_scout.png'
elif class_string == 'Firebug':
class_image = '/images/class_pyro.png'
elif class_string == 'Rocketman':
class_image = '/images/class_soldier.png'
elif class_string == 'Overweight':
class_image = '/images/class_heavy.png'
elif class_string == 'Detonator':
class_image = '/images/class_demoman.png'
elif class_string == 'Healer':
class_image = '/images/class_medic.png'
elif class_string == 'Constructor':
class_image = '/images/class_engineer.png'
elif class_string == 'Infiltrator':
class_image = '/images/class_spy.png'
elif class_string == 'Rifleman':
class_image = '/images/class_sniper.png'
elif class_string == 'Quote':
class_image = '/images/class_quote.png'
else:
class_image = ''
else:
if class_string == 'Runner':
class_image = '/images/class_scout_b.png'
elif class_string == 'Firebug':
class_image = '/images/class_pyro_b.png'
elif class_string == 'Rocketman':
class_image = '/images/class_soldier_b.png'
elif class_string == 'Overweight':
class_image = '/images/class_heavy_b.png'
elif class_string == 'Detonator':
class_image = '/images/class_demoman_b.png'
elif class_string == 'Healer':
class_image = '/images/class_medic_b.png'
elif class_string == 'Constructor':
class_image = '/images/class_engineer_b.png'
elif class_string == 'Infiltrator':
class_image = '/images/class_spy_b.png'
elif class_string == 'Rifleman':
class_image = '/images/class_sniper_b.png'
elif class_string == 'Quote':
class_image = '/images/class_quote_b.png'
else:
class_image = ''
return class_image
#주어진 String에 따라 해당하는 클래스 초상화의 이미지 주소를 반환하는 함수, 해당값이 없을 시 빈 스트링을 반환
def findPortraitImage(class_string, direction):
if direction: #True시 오리지날
class_image = '/images/' + class_string + '_port_o.gif'
else: #False시 반대
class_image = '/images/' + class_string + '_port_a.gif'
return class_image
#플레이타임 템플릿, 시 단위가 존재시 초 단위 삭제,
def makePlaytimeTemplate(user_time):
time_string = ''
time_h = 0
if user_time // 108000:
time_h = user_time // 108000
user_time -= 108000*time_h
if time_h < 100:
time_string += str(time_h) + "h "
else:
time_string += str(time_h) + "h"
if user_time // 1800 and time_h < 100:
time_m = user_time // 1800
user_time -= 1800*time_m
if time_h and time_m:
time_string += str(time_m) + "m"
else:
time_string += str(time_m) + "m "
if not time_h:
time_s = user_time // 30
if time_s or time_string == '':
time_string += str(time_s) + "s"
return time_string
def makeLevelTemplate(user_level):
level_string = '<level style="color: '
if (user_level < 11):
level_string += 'white'
elif (user_level < 21):
level_string += 'tomato'
elif (user_level < 31):
level_string += 'orange'
elif (user_level < 41):
level_string += 'yellow'
elif (user_level < 51):
level_string += 'chartreuse'
elif (user_level < 61):
level_string += 'royalblue'
elif (user_level < 71):
level_string += 'navy'
elif (user_level < 81):
level_string += 'purple'
else:
level_string += 'black'
level_string += '">' + str(user_level) + '</level>'
return level_string
def findClassConstant(class_string):
if (class_string == "Runner"):
return 0
elif (class_string == "Rocketman"):
return 1
elif (class_string == "Rifleman"):
return 2
elif (class_string == "Detonator"):
return 3
elif (class_string == "Healer"):
return 4
elif (class_string == "Constructor"):
return 5
elif (class_string == "Overweight"):
return 6
elif (class_string == "Infiltrator"):
return 7
elif (class_string == "Firebug"):
return 8
elif (class_string == "Quote"):
return 9
def classStringConvert(class_string):
if (class_string == "Runner"):
return "Scout"
elif (class_string == "Rocketman"):
return "Soldier"
elif (class_string == "Rifleman"):
return "Sniper"
elif (class_string == "Detonator"):
return "Demoman"
elif (class_string == "Healer"):
return "Medic"
elif (class_string == "Constructor"):
return "Engineer"
elif (class_string == "Overweight"):
return "Heavy"
elif (class_string == "Infiltrator"):
return "Spy"
elif (class_string == "Firebug"):
return "Pyro"
elif (class_string == "Quote"):
return "Quote"
def rarityIntegerConvert(item_rarity):
if item_rarity == 0:
item_class = "normal"
elif item_rarity == 1:
item_class = "strange"
elif item_rarity == 2:
item_class = "unusual"
elif item_rarity == 3:
item_class = "vintage"
elif item_rarity == 4:
item_class= "self-made"
else:
item_class = "normal"
return item_class
def findWeaponString(class_string):
if (class_string == "Runner"):
return "Scattergun"
elif (class_string == "Rocketman"):
return "Rocketlauncher"
elif (class_string == "Rifleman"):
return "Rifle"
elif (class_string == "Detonator"):
return "Minegun"
elif (class_string == "Healer"):
return "Medigun"
elif (class_string == "Constructor"):
return "Shotgun"
elif (class_string == "Overweight"):
return "Minigun"
elif (class_string == "Infiltrator"):
return "Revolver"
elif (class_string == "Firebug"):
return "Flamethrower"
elif (class_string == "Quote"):
return "Blade"
def partToString(item_part):
if (item_part == 0):
return "Head"
elif (item_part == 1):
return "Torso"
elif (item_part == 2):
return "Leg"
elif (item_part == 3):
return "Weapon"
elif (item_part == 4):
return "Misc"
elif (item_part == 5):
return "Taunt"
elif (item_part == 6):
return "Pet"
elif (item_part == 7):
return "Death Animation"
elif (item_part == 8):
return "Humiliation"
else:
raise IndexError("Item part out of range")
def strangeCountToString(strange_count):
if (strange_count < 10):
return "Strange"
elif (strange_count < 25):
return "Unremarkable"
elif (strange_count < 45):
return "Scarcely Lethal"
elif (strange_count < 70):
return "Mildly Menacing"
elif (strange_count < 100):
return "Somewhat Threatening"
elif (strange_count < 135):
return "Uncharitable"
elif (strange_count < 175):
return "Notably Dangerous"
elif (strange_count < 225):
return "Sufficiently Lethal"
elif (strange_count < 275):
return "Truly Feared"
elif (strange_count < 350):
return "Spectacularly Lethal"
elif (strange_count < 500):
return "Gore-Spattered"
elif (strange_count < 750):
return "Wicked Nasty"
elif (strange_count < 999):
return "Positively Inhumane"
elif (strange_count < 1000):
return "Totally Ordinary"
elif (strange_count < 1500):
return "Face-Melting"
elif (strange_count < 2500):
return "Rage-Inducing"
elif (strange_count < 5000):
return "Server-Clearing"
elif (strange_count < 7500):
return "Epic"
elif (strange_count < 7617):
return "Legendary"
elif (strange_count < 8500):
return "Australian"
elif (strange_count >= 8500):
return "Hale's Own"
else:
raise IndexError("Strange count out of range")
def strangeTypeToString(strange_type):
if (strange_type == 0):
return "Kills"
elif (strange_type == 1):
return "Runners Killed"
elif (strange_type == 2):
return "Firebugs Killed"
elif (strange_type == 3):
return "Rocketmans Killed"
elif (strange_type == 4):
return "Overweights Killed"
elif (strange_type == 5):
return "Detonators Killed"
elif (strange_type == 6):
return "Healers Killed"
elif (strange_type == 7):
return "Constructors Killed"
elif (strange_type == 8):
return "Infiltrators Killed"
elif (strange_type == 9):
return "Riflemans Killed"
elif (strange_type == 10):
return "Quotes Killed"
elif (strange_type == 11):
return "Sentries Destroyed"
elif (strange_type == 12):
return "Invulns"
elif (strange_type == 13):
return "Knife Kills"
else:
raise IndexError("Strange type out of range")
#이 상수 추가해야 아이템 업로드 페이지에서 제대로 작동함
_UNUSUALS = [0, 1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103]
def unusualTypeToString(unusual_type):
#Circling 시리즈
if (unusual_type == 0):
return "Circling GG Logo"
elif(unusual_type == 1):
return "Circling Heart"
elif(unusual_type == 2):
return "Circling Peace Sign"
elif(unusual_type == 3):
return "Strolling Blackmage"
elif(unusual_type == 4):
return "Haunted Ghosts"
elif(unusual_type == 5):
return "Circling Coin"
elif(unusual_type == 6):
return "Orbiting Invaders"
elif(unusual_type == 7):
return "Orbiting Saturn"
#머리 위치에서 고정형
elif(unusual_type == 100):
return "Green Energy"
elif(unusual_type == 101):
return "Purple Energy"
elif(unusual_type == 102):
return "Red Energy"
elif(unusual_type == 103):
return "Blue Energy"
else:
return ""
#K, M단위로 수치 표시
def strlize(num):
if (num >= 1000):
return "%.1f" %(num/1000.0) + "K"
elif (num >= 1000000):
return "%.1f" %(num/1000000.0) + "M"
else:
return str(num)
def getMaxExp(current_level):
return 1500*current_level
#=========================================================================================================================#
#PAGES#
#=========================================================================================================================#
#메인 페이지
class MainPage(webapp2.RequestHandler):
def get(self):
css = """
<link href='https://fonts.googleapis.com/css?family=Press+Start+2P' rel='stylesheet' type='text/css'>
<style>
@font-face {
font-family: "Mother";
src: url('/fonts/apple_kid.eot'); /* IE9 Compat Modes */
src: url('/fonts/apple_kid.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/apple_kid.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/apple_kid.woff') format('woff'), /* Pretty Modern Browsers */
url('/fonts/apple_kid.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/apple_kid.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: "Saturn";
src: url('/fonts/saturn_boing.eot'); /* IE9 Compat Modes */
src: url('/fonts/saturn_boing.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/saturn_boing.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/saturn_boing.woff') format('woff'), /* Pretty Modern Browsers */
url('/fonts/saturn_boing.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/saturn_boing.svg#svgFontName') format('svg'); /* Legacy iOS */
}
html, body {
height:100%;
width:100%;
padding: 0;
margin: 0;
}
html{
display: table;
}
body{
font-family: 'Press Start 2P', sans-serif, cursive;
display: table-cell;
background: #C6BEBC; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(#A29994, #C6BEBC, #716967); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#A29994, #C6BEBC, #716967); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#A29994, #C6BEBC, #716967); /* For Firefox 3.6 to 15 */
background: linear-gradient(#A29994, #C6BEBC, #716967);
text-align: center;
color: white;
}
div.Menu{
width: 100%;
height: 68px;
background: #363030; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(#363030, #A29994); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#363030, #A29994); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#363030, #A29994); /* For Firefox 3.6 to 15 */
background: linear-gradient(#363030, #A29994)
display: inline-block;
margin: auto;
margin-bottom: 0px;
text-align: center;
}
p.Menu{
float: left;
height: 36px;
}
a.menu{
font-size: 14px;
margin-right: 20px;
}
img.menu{
width: 36px;
height: 36px;
}
div.motd{
margin: auto;
margin-bottom: 50px;
padding: auto;
clear: left;
}
/* unvisited link */
a:link {
color: white;
text-decoration: none;
}
/* visited link */
a:visited {
color: white;
text-decoration: none;
}
/* mouse over link */
a:hover {
color: hotpink;
text-decoration: none;
}
/* selected link */
a:active {
color: hotpink;
text-decoration: none;
}
a.first{
color: yellow;
}
p{
width: 100%;
image-rendering: crisp-edges;
image-rendering: pixelated;
}
#normal{
color: #F7DC07;
}
#strange{
color: #CF6A32;
}
#unusual{
color: #8650AC;
}
#vintage{
color: #476291;
}
#self-made{
color: #70B04A;
}
p.motd-head{
background-image:url("/images/motd_head.png");
background-repeat: no-repeat;
background-position:center center;
background-size: 1024px 180px;
height: 180px;
margin: 0;
}
p.motd-body{
background-image:url("/images/motd_body.png");
background-repeat: repeat-y;
background-position:center center;
background-size: 1024px 136px;
height: 242px;
margin: 0;
}
p.motd-tail{
background-image:url("/images/motd_tail.png");
background-repeat: no-repeat;
background-position:center center;
background-size: 1024px 180px;
height: 180px;
margin: 0;
}
div.quest{
margin-bottom: 50px;
}
table.quest{
font-family: Mother, sans-serif;
vertical-align: middle;
line-height: 1.5;
color: #716967;
text-align: justify;
width: 608px;
margin: auto;
margin-top: 20px;
border-spacing: 0px 0px;
}
td.head{
background-image:url("/images/mother_head.png");
background-repeat: no-repeat;
background-position:center center;
background-size: 608px 20px;
height: 20px;
margin: 0;
}
td.body{
background-image:url("/images/mother_body.png");
background-repeat: repeat-y;
background-position:center center;
background-size: 608px 4px;
height: 100px;
margin: 0;
}
td.tail{
background-image:url("/images/mother_tail.png");
background-repeat: no-repeat;
background-position:center center;
background-size: 608px 20px;
height: 20px;
margin: 0;
}
tr.quest{
height: 20px;
}
span.title{
font-size: 40px;
text-shadow: 2px 2px #000000;
font-family: Saturn;
color: #716967;
}
span.questname{
margin-left: 30px;
text-align: justify;
font-size: 50px;
color: white;
}
span.questcontent{
margin-left: 30px;
text-align: justify;
font-size: 30px;
}
span.questcount{
margin-left: 10px;
text-align: justify;
font-size: 30px;
}
span.questreward{
float: right;
margin-right: 50px;
text-align: justify;
font-size: 30px;
color: yellow;
}
div.rank{
text-align: center;
margin-bottom: 100px;
}
fieldset{
display: inline;
Border: 5px;
border-style: solid;
border-radius:0.4em;
}
table.rank{
width: 800px;
vertical-align: middle;
text-align: center;
margin: auto;
}
th{
color: #8E8464;
}
tr{
height: 32px;
}
tr.first{
color: yellow;
}
div.howto{
text-align: center;
width: 100%;
line-height: 5;
}
div.copyright{
text-align: center;
width: 100%;
color: #FBECCB;
line-height: 2;
}
</style>
"""
script = """
<script type="text/javascript">
if (window.top.location != window.location) {
window.top.location = window.location;
}
</script>
"""
#로그인 검정, 로그인이 되었을시 user_logged_on의 값은 True, 아닐시 False
user = users.get_current_user()
user_id = ''
user_logged_on = False
if user:
current_user = ndb.gql('SELECT * FROM UserEntity WHERE google_id=:1', user).get()
if current_user:
user_id = current_user.user_id
user_logged_on = True
#페이지 시작
html = '<HTML>'
html += '<HEAD>' + '<TITLE>Gang Garrison 2 Stats</TITLE>' + css + script + '</HEAD>'
html += '<BODY>'
#상단 메뉴, 로그인시의 메뉴, 검색창, 로그인 페이지를 포함
html += '<div class="Menu">'
html += '<p class="Menu">'
html += '<a class="menu" href="/rank"><img class="menu" src="/images/menu_leaderboard.png" title="LeaderBoard"></a>'
html += '<a class="menu" href="/search"><img class="menu" src="/images/menu_search.png" title="Search"></a>'
html += '<a class="menu" href="/gallery"><img class="menu" src="/images/menu_gallery.png" title="Item Gallery"></a>'
html += '<a class="menu" href="/down"><img class="menu" src="/images/menu_download.png" title="Download"></a>'
if user_logged_on:#로그인 되었을시의 백팩과 로드아웃, 가챠 메뉴 표시
html += '<a class="menu" href="/backpack?id=' + user_id + '"><img class="menu" src="/images/menu_backpack.png" title="Backpack"></a>'
html += '<a class="menu" href="/loadout"><img class="menu" src="/images/menu_loadout.png" title="Loadout"></a>'
html += '<a class="menu" href="/gacha"><img class="menu" src="/images/menu_gacha.png" title="Gacha"></a>'
html += '<a class="menu" href="/mytrade"><img class="menu" src="/images/menu_trade.png" title="My Trade"></a>'
html += '<a class="menu" href="/market"><img class="menu" src="/images/menu_market.png" title="Market"></a>'
html += ''#검색창
if user_logged_on:
if current_user.user_avatar:
html += '<a href="/myprofile"><img class="menu" src="/upload?img_id=%s" title="My Profile"></a> ' %current_user.key.urlsafe()
else:
html +='<a href="/myprofile"><img src="/images/gg2slogo.png" title="My Profile"></a> '
html += '<a class="menu" style="color: yellow;">' + str(current_user.user_coin) + 'G</a>'
logout_url = users.create_logout_url('/')
html += '<a class="menu" href="' + logout_url + '">Logout</a>'
else:
html += '<a class="menu" href="%s">Login</a>' %users.create_login_url('/')
html += '<a class="menu" class="register" href="/register">Register</a>'
if str(self.request.headers.get('X-AppEngine-Country')) == 'KR':
html += '<a class="menu" href="http://cafe.naver.com/ganggarrison2k/16040">'
else:
html += '<a class="menu" href="http://www.ganggarrison.com/forums/index.php?topic=37158.0">'
html += '<img class="menu" src="/images/menu_howto.png" title="How To Use">'
html += '</a>'
html += '</p>'
html += '</div>'
if user_logged_on:
if (current_user.user_region != str(self.request.headers.get('X-AppEngine-Country'))):
current_user.user_region = str(self.request.headers.get('X-AppEngine-Country'))
current_user.put()
#NOTICE
if user_logged_on:
offer_count = ndb.gql('SELECT __key__ FROM OfferEntity WHERE offer_targetuser=:1', user).count()
log_list = ndb.gql('SELECT * FROM LogEntity WHERE log_owner=:1 AND log_checked=False', user)
reply_count = ndb.gql('SELECT __key__ FROM ReplyEntity WHERE reply_target=:1 AND reply_checked=False', user).count()
html += '<div class="notice" style="font-family: Mother, sans-serif; text-shadow: 2px 2px #454545;">'
html += '<img src="/images/icon_notice.png">'
html += '<span class="title"> NOTICE </span>'
html += '<img src="/images/icon_notice.png">'
ndb_put_list = []
if offer_count:
html += '<br>'
html += '<span class="questname" style="text-align: center;">'
html += '<image src="images/mother_dot.png"> '
html += 'There\'re <span style="color: yellow;">' + str(offer_count) + '</span> offers for your item.'
html += '</span>'
if reply_count:
html += '<br>'
html += '<span class="questname" style="text-align: center;">'
html += '<image src="images/mother_dot.png"> '
html += 'There\'re <span style="color: yellow;">' + str(reply_count) + '</span> unread comments on your profile.'
html += '</span>'
for log in log_list:
html += '<br>'
html += '<span class="questname" style="text-align: center;">'
html += '<image src="images/mother_dot.png"> '
html += log.log_content
html += '</span>'
log.log_checked = True
ndb_put_list.append(log)
if ndb_put_list:
ndb.put_multi(ndb_put_list)
html += '</div>'
#MOTD
html += '<div class="motd" style="text-align: center;">'
html += '<p class="motd-head"></p>'
html += '<p class="motd-body" style="font-size: 48px; font-family: Mother, sans-serif; text-shadow: 2px 2px #454545;">'
html += '<img src="/images/gg2slogo_200.png">'
html += '<br>'
html += '<span>Gang Garrison 2 Stats</span>'
html += '</p>'
html += '<p class="motd-tail">'
html += '</p>'
html += '</div>'
#일퀘
if user_logged_on:
html += '<div class="quest">'
html += '<span class="title">DAILY QUESTS</span>'
#Memcache Read
quest_list = memcache.get(current_user.user_id + ':quest')
if quest_list is None: