parent
18438a63f1
commit
f91b11e293
@ -0,0 +1,57 @@
|
||||
import string
|
||||
import json
|
||||
|
||||
|
||||
class RowModel(object):
|
||||
def __init__(self, row):
|
||||
self._row = row
|
||||
self.id = row["_id"]
|
||||
|
||||
def __getattr__(self, name):
|
||||
try:
|
||||
return self._row[name]
|
||||
except IndexError:
|
||||
raise AttributeError("'%s' object has no attribute '%s'"
|
||||
% (self.__class__.__name__, name))
|
||||
|
||||
def as_dict(self):
|
||||
d = dict(self._row)
|
||||
d["id"] = d["_id"]
|
||||
del d["_id"]
|
||||
return d
|
||||
|
||||
def as_json(self):
|
||||
data = self.as_dict()
|
||||
return json.dumps(data)
|
||||
|
||||
|
||||
class Quest(RowModel):
|
||||
_full_template = string.Template(
|
||||
"$name ($hub $stars* $rank)"
|
||||
"\n Goal: $goal"
|
||||
"\n Sub : $sub_goal"
|
||||
)
|
||||
|
||||
_one_line_template = string.Template(
|
||||
"$name ($hub $stars* $rank)"
|
||||
)
|
||||
|
||||
def __init__(self, quest_row, quest_rewards=None):
|
||||
super(Quest, self).__init__(quest_row)
|
||||
|
||||
self.rewards = quest_rewards
|
||||
|
||||
def is_multi_monster(self):
|
||||
return (" and " in self.goal
|
||||
or "," in self.goal
|
||||
or " all " in self.goal)
|
||||
|
||||
def one_line_u(self):
|
||||
return self._one_line_template.substitute(self.as_dict())
|
||||
|
||||
def full_u(self):
|
||||
return self._full_template.substitute(self.as_dict())
|
||||
|
||||
def __unicode__(self):
|
||||
return self.full_u()
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
|
||||
|
||||
class SkillEnum(object):
|
||||
_names = dict()
|
||||
|
||||
@classmethod
|
||||
def name(cls, skill_id):
|
||||
return cls._names[skill_id]
|
||||
|
||||
|
||||
class CapSkill(SkillEnum):
|
||||
NONE = 0
|
||||
EXPERT = 1
|
||||
MASTER = 2
|
||||
GOD = 3
|
||||
|
||||
_names = { NONE: "No skills",
|
||||
EXPERT: "Capture Expert",
|
||||
MASTER: "Capture Master",
|
||||
GOD: "Capture God" }
|
||||
|
||||
|
||||
class LuckSkill(SkillEnum):
|
||||
NONE = 0
|
||||
GOOD = 1
|
||||
GREAT = 2
|
||||
AMAZING = 3
|
||||
|
||||
_names = { NONE: "No skills",
|
||||
GOOD: "Good Luck",
|
||||
GREAT: "Great Luck",
|
||||
AMAZING: "Magnificent Luck" }
|
||||
|
||||
|
||||
class CarvingSkill(SkillEnum):
|
||||
NONE = 0
|
||||
PRO = 0 # prevent knockbacks but no extra carves
|
||||
FELYNE_LOW = 1
|
||||
FELYNE_HI = 2
|
||||
CELEBRITY = 3
|
||||
GOD = 4
|
||||
|
||||
_names = { NONE: "No skills",
|
||||
FELYNE_LOW: "Felyne Carver Lo",
|
||||
FELYNE_HI: "Felyne Carver Hi",
|
||||
CELEBRITY: "Carving Celebrity",
|
||||
GOD: "Carving God" }
|
||||
|
||||
|
||||
QUEST_A = "A"
|
||||
QUEST_B = "B"
|
||||
QUEST_SUB = "Sub"
|
||||
|
||||
Loading…
Reference in new issue