示例#1
0
 def start(self):
     self.title = u'Рынок'
     sp = spell.get(self.spell_id)
     self.text = u'Торговец предлагает вам купить заклинание %s за %s золотых.' % (sp.name, self.price)
     self.options = _(u'''
         agree: Согласиться
         exit: Отказаться
     ''')
示例#2
0
 def agree(self):
     if self.user['gold'] >= self.price:
         s = spell.get(self.spell_id)
         self.user.private_message(u'Вы купили {:s} за %s золотых.' % self.price, s.js_link())
         self.user['gold'] -= self.price
         self.user['reserve'].add(s.id)
         return False
     else:
         self.text = u'У вас не хватает золота!'
示例#3
0
 def shop_sell(self):
     self._checkloc("shop")
     spell_id = self.q["spell_id"]
     if not self.user['reserve'].has(spell_id):
         self._error('User doesn\'t have this card')
     s = spell.get(spell_id)
     sell_price = int(round(s.price * 0.25))
     self.user["reserve"].remove(s.id)
     self.user["gold"] += sell_price
     self.user.save()
     return None
示例#4
0
 def shop_buy(self):
     self._checkloc("shop")
     s = spell.get(self.q["spell_id"])
     if not s.shop:
         self._error("Not for sell")
     if self.user["gold"] < s.price:
         self._reject("Not enough gold")
     self.user["gold"] -= s.price
     self.user["reserve"].add(s.id)
     self.user.save()
     return None
示例#5
0
 def process_casts(self):
     ''' Обработка кастов заклинаний '''
     to_cast = [(f.card_in_hand_by_id(f.move["card"]).spell, f, self.fighter_by_id(f.move["cast_target"]), f.card_in_hand_by_id(f.move["card"])) for f in self.fighters() if f.move and f.move.get("card")]
     to_cast += [(spell.get(f.move["spell"]), f, self.fighter_by_id(f.move["cast_target"]), None) for f in self.fighters() if f.move and f.move.get("spell")]
     to_cast.sort(key=lambda item: item[0].priority)
     for (sp, caster, target, card) in to_cast:
         if not caster.can_move():
             continue
         caster.mana += sp.mana
         sp._cast(caster, target)
         if card:
             caster.hand.remove(card)
示例#6
0
 def deck_edit(self):
     user = self.user
     if user["loc"] == "fight" and user.fight().status != "over":
         self._error("Cannot edit deck while fighting")
     qdeck = self.q["deck"]
     qres = self.q["reserve"]
     if sum(qdeck.itervalues()) < constants.min_deck:
         self._error("Invalid deck")
     qq = combine_counter_dicts(qdeck, qres)
     old = combine_counter_dicts(user["deck"].dict, user["reserve"].dict)
     if qq != old:
         self._error("Invalid card set")
     uniques = 0
     for id, count in qdeck.iteritems():
         s = spell.get(id)
         if count > constants.max_cards[s.rarity]:
             self._error("Too many cards: " + id)
         if s.rarity >= 3:
             uniques += count
     if uniques > 1:
         self._error("Too many uniques!")
     user.update({"deck": deck.Deck(qdeck), "reserve": deck.Deck(qres)})
     return None
示例#7
0
文件: mob.py 项目: alexbft/Karty-RPG
 def select_target(self):
     try:
         return random.choice(spell.get(self.spell).targets(self.fighter)).id
     except IndexError:
         return None
示例#8
0
文件: deck.py 项目: alexbft/Karty-RPG
 def js(self):
     return {"dict": self.dict, "spells": dict((id, spell.get(id).js()) for id in self.dict.iterkeys())}
示例#9
0
 def js_load(obj):
     global spell_module
     if spell_module == None:
         import spell as spell_module
     return spell_module.get(obj)
示例#10
0
文件: loot.py 项目: alexbft/Karty-RPG
 def open(self):
     ensure_imports()
     return OpenLoot(self._type, spell.get(self.spell_id))
示例#11
0
文件: card.py 项目: alexbft/Karty-RPG
 def spell(self):
     if self._spell == None:
         self._spell = spell.get(self.spell_id)
     return self._spell