45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
|
|
from uuid import uuid4
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
from warchron.model.round import Round
|
||
|
|
|
||
|
|
class Campaign:
|
||
|
|
def __init__(self, name):
|
||
|
|
self.id = str(uuid4())
|
||
|
|
self.name = name
|
||
|
|
self.month = datetime.now().month
|
||
|
|
self.entrants = {}
|
||
|
|
self.rounds = {}
|
||
|
|
self.is_over = False
|
||
|
|
|
||
|
|
def set_id(self, new_id):
|
||
|
|
self.id = new_id
|
||
|
|
|
||
|
|
def set_name(self, new_name):
|
||
|
|
self.name = new_name
|
||
|
|
|
||
|
|
def set_month(self, new_month):
|
||
|
|
self.month = new_month
|
||
|
|
|
||
|
|
def set_state(self, new_state):
|
||
|
|
self.is_over = new_state
|
||
|
|
|
||
|
|
def toDict(self):
|
||
|
|
return {
|
||
|
|
"id" : self.id,
|
||
|
|
"name" : self.name,
|
||
|
|
"month" : self.month,
|
||
|
|
"entrants" : self.entrants,
|
||
|
|
"rounds" : self.rounds,
|
||
|
|
"is_over": self.is_over
|
||
|
|
}
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def fromDict(id, name, month, entrants, rounds, is_over):
|
||
|
|
tmp = Campaign(name=name)
|
||
|
|
tmp.set_id(id)
|
||
|
|
tmp.set_month(month)
|
||
|
|
## entrants placeholder
|
||
|
|
## rounds placeholder
|
||
|
|
tmp.set_state(is_over)
|
||
|
|
return tmp
|