-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.py
74 lines (65 loc) · 2.66 KB
/
dev.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
#!/usr/bin/env python
'''
A module used for development
'''
import random
from datetime import datetime, timedelta
from models import *
from rating import recalculate_ratings
def add_test_data_all():
add_test_data_players()
add_test_data_games(20)
def add_test_data_players():
print "Creating players..."
Player(nick = "Andriod").put()
Player(nick = "Dust").put()
Player(nick = "Kartoffel").put()
Player(nick = "Ninja").put()
Player(nick = "Knsnsns").put()
Player(nick = "Lolmannen").put()
Player(nick = "Kaku").put()
Player(nick = "Gerrard").put()
Player(nick = "Torres").put()
print "Creating players DONE"
def add_test_data_games(number_of_games):
for i in range(number_of_games):
add_test_data_randomized_game(datetime.now() - timedelta(days=number_of_games-i))
recalculate_ratings()
print "Creating games data DONE"
def add_test_data_randomized_game(game_date):
game_key = Game(
# After finish values
date = game_date,
duration_seconds = random.randint(40,300)*60,
# Settings from lobby Game Settings
game_type = random.choice(list(Game.game_type._choices)),
size = random.choice(list(Game.size._choices)),
difficulty = random.choice(list(Game.difficulty._choices)),
resources = random.choice(list(Game.resources._choices)),
population = random.choice(list(Game.population._choices)),
game_speed = random.choice(list(Game.game_speed._choices)),
reveal_map = random.choice(list(Game.reveal_map._choices)),
starting_age = random.choice(list(Game.starting_age._choices)),
treaty_length = random.choice(list(Game.treaty_length._choices)),
victory = random.choice(list(Game.victory._choices)),
team_together = True,
all_techs = True,
# Settings from Objective screen ingame
location = random.choice(list(Game.location._choices)),
# Special settings
trebuchet_allowed = False
).put()
players = Player.query().fetch()
random.shuffle(players)
total_players_this_game = random.randint(2,8)
for i in range(total_players_this_game):
PlayerResult(
player = players[i].key, # Might get index out of range, thats because of cache issues. Need to re rerun add_test_data_randomized_game()
game = game_key,
game_date = game_date,
is_winner = True if (i < total_players_this_game / 2) else False,
score = random.randint(2000,40000),
team = 1 if (i < total_players_this_game / 2) else 2,
civilization = random.choice(list(CIVILIZATIONS)),
stats_rating = 0
).put()