Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from commands.say import SayCommand
- from players.entity import Player
- from plugins.info import PluginInfo
- from motdplayer import Page
- info = PluginInfo(__name__)
- class ShopPage(Page):
- plugin_id = "wcs"
- page_id = "shop"
- def on_data_received(self, data):
- player = # тут получаешь своего игрока с помощью self.index
- if data['action'] == "get-items":
- item_data = []
- for item in player.item_hero.items.values():
- item_data.append({
- 'id': item.id,
- 'name': item.name,
- 'icon': item.icon,
- 'cost': item.cost,
- })
- self.send_data({
- 'action': "items-delivery",
- 'availableItems': item_data, # тут информация о доступных предметах
- })
- return
- if data['action'] == "buy-item":
- item_id = data['itemId']
- if item_id not in player.item_hero.items:
- return
- item = player.item_hero.items[item_id]
- item.level += 1
- player.item_hero.coins -= item.cost
- return
- @SayCommand('!shop')
- def say_shop(command, index, team_only):
- ShopPage.send(index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement