-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.py
More file actions
176 lines (125 loc) · 4.87 KB
/
Copy pathModel.py
File metadata and controls
176 lines (125 loc) · 4.87 KB
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
import pygame
import loadData
from EventManager import *
#should be all the data associated with the current game
#model has the current selection
class GameEngine(object):
def __init__(self, evManager, loadData):
self.evManager = evManager
evManager.RegisterListener(self)
self.running = False
self.loadData = loadData
#make phase and such go here
self.phase = 'mainmenu'
self.gamePhase = 0
self.players = []
self.gameTerritories = {}
self.turn = 0
self.phaseIndictaorPos = (400,500)
self.initalPlacement = True
self.initalTurns = 0
def notify(self, event):
if isinstance(event, QuitEvent):
self.running = False
def run(self):
self.running = True
self.evManager.Post(InitializeEvent())
while self.running:
newTick = TickEvent()
self.evManager.Post(newTick)
def getPlayers(self, array):
for i in range(len(array)):
self.players.append (Player(i+ 1, array[i], 40 - ((len(self.players ) - 2) * 5)))
self.initalTurns = 40 - ((len(self.players ) - 2) * 5) + len(self.players)
self.updateTurn()
def updateGamePhase(self):
if self.initalPlacement:
total = 0
for i in self.players:
total += i.armies
print(total)
if i == 0:
self.intialPlacment = false
else:
self.updateTurn()
else:
if self.gamePhase == 2:
self.updateTurn()
self.gamePhase = 0
else:
self.gamePhase += 1
self.phaseIndictaorPos = (400 + 100 * self.gamePhase, 500)
def updateTurn(self):
if self.turn == len(self.players):
self.turn =1
else:
self.turn += 1
for i in self.players:
i.updateSelection(self.turn)
def initalFortify(self, id):
if id in self.gameTerritory:
print("No g already taken")
return
else:
self.
#gameTerritory dictionary {"territoyname/id": player, amount of units, ...}
#intital fortify is going to check up to 42 if the current selected territory is in the dictionary
#if it is send back and error if it is not then add it to the dictionary as specified
#after 42 it is not going to check if it is IN the territory but if the CURRENT player OWNS that territory
#VARIABLE
# need to have some grid like data structure loaded in so we can check if the player is selecting an adjacent tile
# Territory CLASS
# the model here needs to have all of the territories
#needs to store information about the territories
# - what contient, - how many troops, does it need to know which player it is apart of,
# how many armies they give
class Territory():
def __init__(self):
self.id
self.name
self.continent
self.armies
self.income
#player CLASS
# all need to have data associated with them
# - turn order, - what contients they own, - cards they have
class Player():
def __init__(self, id, color, armies):
self.id = id
self.surface = pygame.Surface((50,50))
self.dest = (id * 50, 500)
self.color = self.checkColor(color)
self.surface.fill(self.color)
self.armies = armies
self.continentsOwned = []
#potentially split this into different arrays for the differnt cards
self.cards = []
def updateSelection(self, turn):
print(turn, self.id)
if self.id == turn:
self.surface.fill((255,255,255), self.surface.get_rect().inflate(-10,-10))
else:
self.surface.fill(self.color)
def checkColor(self, color):
if color == "red":
return((255, 0 , 0))
elif color == "blue":
return((0, 0, 255))
elif color == "pink":
return((200, 100, 0))
elif color == "teal":
return ((0, 200, 100))
#game CLASS
# needs to know what phase the game is in, does it need to know the player
# - menu, options ( should just extend the menu ), player selection
# - put down units phase until last unit
# - turn one player one, im guessing
# - recieve units, they decied where to put them
# - preform attacks
# - fortify, which means moving armies form one and only one position, to another adjacent tile
#lass Phase():
#class Fortify(Phase):
# def __init__(self):
# self.phase
#class Attack(Phase):
#class Placing(Phase):