/
db_initialization.py
182 lines (149 loc) · 4.81 KB
/
db_initialization.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
#SQLAlchemy stuff
from models import (
DBSession,
metadata
)
from sqlalchemy import create_engine
import settings
engine = create_engine('mysql+mysqldb://'+settings.db_user+':'+settings.db_password+'@'+settings.db_host+'/'+settings.db_name)
DBSession.configure(bind=engine)
metadata.bind = engine
import models
metadata.drop_all()
DBSession.flush()
metadata.create_all()
from business.game import Game
game = Game('The game you just lost')
DBSession.add(game)
from business.game.player import PlayerGame
player = PlayerGame('Me')
DBSession.add(player)
player.game = game
from business.army.army import Army
player.buried_army = Army('Buried stuff')
DBSession.add(player.buried_army)
player.dead_army = Army('Dead stuff')
DBSession.add(player.dead_army)
player.reserve_army = Army('Reserve stuff')
DBSession.add(player.reserve_army)
player.summon_army = Army('Summonable stuff')
DBSession.add(player.summon_army)
from business.element import Element
blue = Element('Blue', 'Air', 'a')
DBSession.add(blue)
red = Element('Red', 'Fire', 'f')
DBSession.add(red)
green = Element('Green', 'Water', 'w')
DBSession.add(green)
gold = Element('Gold', 'Earth', 'e')
DBSession.add(gold)
black = Element('Black', 'Death', 'd')
DBSession.add(black)
ivory = Element('Ivory', 'None', 'i')
DBSession.add(ivory)
#Well, white could be represented by having the 5 element, but having a white element mean it's easier to know everything is here
white = Element('White', 'All', 'al')
DBSession.add(white)
DBSession.flush()
from business.dice.dice_type import DiceType
common = DiceType('common unit', 1, 1)
DBSession.add(common)
uncommon = DiceType('uncommon unit', 2, 2)
DBSession.add(uncommon)
rare = DiceType('rare unit', 3, 3)
DBSession.add(rare)
monster = DiceType('monster unit', 4, 4)
DBSession.add(monster)
common = DiceType('common item', 1, 1.0)
DBSession.add(common)
uncommon = DiceType('uncommon item', 2, 1.5)
DBSession.add(uncommon)
rare = DiceType('rare item', 3, 2.0)
DBSession.add(rare)
artifact = DiceType('artifact item', 4, 4)
DBSession.add(artifact)
medallion = DiceType('medallion item', 4, 4)
DBSession.add(medallion)
DBSession.flush()
from business.dice.dice_role import DiceRole
#regular troop
hm = DiceRole('Heavy Melee', 1)
DBSession.add(hm)
lm = DiceRole('Light Melee', 2)
DBSession.add(lm)
mi = DiceRole('Archer', 4)
DBSession.add(mi)
mh = DiceRole('Heavy Archer', 5)
DBSession.add(mh)
ca = DiceRole('Cavalry', 6)
DBSession.add(ca)
ma = DiceRole('Mage', 8)
DBSession.add(ma)
lm = DiceRole('Mage Warrior', 7)
DBSession.add(lm)
sb = DiceRole('Shield Bearer', 3)
DBSession.add(sb)
#4-health dice
monster = DiceRole('Monster', 9)
DBSession.add(monster)
ch = DiceRole('Champion', 10)
DBSession.add(ch)
#magic items
sh = DiceRole('Magic Shoes', 11)
DBSession.add(sh)
sw = DiceRole('Magic Sword', 12)
DBSession.add(sw)
ar = DiceRole('Magic Arrow', 13)
DBSession.add(ar)
jw = DiceRole('Magic Jewelry', 14)
DBSession.add(jw)
shield = DiceRole('Magic Shield', 15)
DBSession.add(shield)
art = DiceRole('Artifact', 16)
DBSession.add(art)
med = DiceRole('Medallion', 17)
DBSession.add(med)
DBSession.flush()
from business.race import Race
coral_elves = Race('Coral Elf', 'CoralElf', 'ce', 1, '00FFFF')
DBSession.add(coral_elves)
lava_elves = Race('Lava Elf', 'LavaElf', 'le', 2, '7F0000')
DBSession.add(lava_elves)
dwarves = Race('Dwarf', 'Dwarf', 'dw', 3, 'FF4000')
DBSession.add(dwarves)
goblins = Race('Goblin', 'Goblin', 'go', 4, '404000')
DBSession.add(goblins)
amazon = Race('Amazon', 'Amazon', 'am', 5, 'DDDDDD')
DBSession.add(amazon)
firewalker = Race('Firewalker', 'FireWalker', 'fiw', 6, '7F007F')
DBSession.add(firewalker)
undead = Race('Undead', 'Undead', 'ud', 7, '333333')
DBSession.add(undead)
feral = Race('Feral', 'Feral', 'fe', 8, '00AC00')
DBSession.add(feral)
swamp_stalker = Race('Swamp Stalker', 'SwampStalker', 'ss', 9, '004000')
DBSession.add(swamp_stalker)
frostwing = Race('Frost Wing', 'FrostWing', 'frw', 10, '000080')
DBSession.add(frostwing)
scalder = Race('Scalder', 'Scalder', 'sc', 11, '7F4000')
DBSession.add(scalder)
treefolk = Race('treefolk', 'Treefolk', 'tf', 12, '00FF00')
DBSession.add(treefolk)
eldarim = Race('Eldarim', 'Eldarim', 'el', 13, 'FFFFFF', break_by_color=True)
DBSession.add(eldarim)
dragonkin = Race('Dragonkin', 'DragonKin', 'dk', 14, '888888', break_by_color=True)
DBSession.add(dragonkin)
magic_item = Race('Magic Items', 'MagicItems', 'mi', 15, '666666', break_by_color=True)
DBSession.add(magic_item)
medallion = Race('Medallion', 'Medallion', 'me', 16, '666666')
DBSession.add(medallion)
from business.army.position import ArmyPosition
regular = ArmyPosition('Army')
DBSession.add(regular)
reserve = ArmyPosition('Reserve Area', is_reserve=True)
DBSession.add(reserve)
dua = ArmyPosition('Dead Unit Area', is_dead=True)
DBSession.add(dua)
bua = ArmyPosition('Buried Unit Area', is_buried=True)
DBSession.add(bua)
DBSession.flush()