Compare commits
1 Commits
445c51eec7
...
master
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
d40c7addfb |
13
bot.py
13
bot.py
@@ -1,3 +1,5 @@
|
|||||||
|
import random as _rand
|
||||||
|
|
||||||
from telegram.ext import Application
|
from telegram.ext import Application
|
||||||
from telegram.ext import CommandHandler
|
from telegram.ext import CommandHandler
|
||||||
from telegram.ext import MessageHandler
|
from telegram.ext import MessageHandler
|
||||||
@@ -8,10 +10,18 @@ from telegram import ReplyKeyboardRemove
|
|||||||
from utils import logs as _log
|
from utils import logs as _log
|
||||||
|
|
||||||
from entities import arena as _arena
|
from entities import arena as _arena
|
||||||
|
from entities.items import syms as _isyms
|
||||||
from bot_libs import special_commands as _scmd
|
from bot_libs import special_commands as _scmd
|
||||||
from bot_libs import syms as _botsyms
|
from bot_libs import syms as _botsyms
|
||||||
from bot_libs import commands_handling as _cmd
|
from bot_libs import commands_handling as _cmd
|
||||||
|
|
||||||
|
def bot_get_random_items():
|
||||||
|
items= []
|
||||||
|
nitems= _rand.randint(3,5)
|
||||||
|
for n in range(nitems):
|
||||||
|
itype= _rand.sample(_isyms.ITEMS_LIST, 1)[0]
|
||||||
|
items.append(itype)
|
||||||
|
return items
|
||||||
|
|
||||||
async def bot_start(update, context):
|
async def bot_start(update, context):
|
||||||
await update.message.reply_text(_botsyms.START_MSG)
|
await update.message.reply_text(_botsyms.START_MSG)
|
||||||
@@ -30,7 +40,8 @@ async def bot_start(update, context):
|
|||||||
|
|
||||||
chat_id = update.effective_chat.id
|
chat_id = update.effective_chat.id
|
||||||
_log.log_debug(f'bot_start: {chat_id} - I\'m building the world\'s game...')
|
_log.log_debug(f'bot_start: {chat_id} - I\'m building the world\'s game...')
|
||||||
Arena= _arena.BrSimArena()
|
items= bot_get_random_items()
|
||||||
|
Arena= _arena.BrSimArena(items= items)
|
||||||
|
|
||||||
await update.message.reply_text('Ho creato il mondo di gioco', reply_markup=reply_markup)
|
await update.message.reply_text('Ho creato il mondo di gioco', reply_markup=reply_markup)
|
||||||
context.application.bot_data['arena'] = Arena
|
context.application.bot_data['arena'] = Arena
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ class BrSimArena():
|
|||||||
|
|
||||||
def init_items(self, items):
|
def init_items(self, items):
|
||||||
if not items: return
|
if not items: return
|
||||||
for item in items:
|
for item_id in items:
|
||||||
for itype, quantity in item.items():
|
I= _items.BrSimItem(item_id)
|
||||||
for i in range(quantity): self.items.append(_items.BrSimItem(wrype))
|
self.items.append(I)
|
||||||
|
|
||||||
def next_day(self):
|
def next_day(self):
|
||||||
self.day+= 1
|
self.day+= 1
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ class BrSimMap():
|
|||||||
self.game_map.append(_copy.deepcopy(width))
|
self.game_map.append(_copy.deepcopy(width))
|
||||||
#_logs.log_debug(f'init_map_matrix: {self.game_map}')
|
#_logs.log_debug(f'init_map_matrix: {self.game_map}')
|
||||||
_logs.log_debug(f'players: %s'% [(p.get_name(), p.get_coordinates()) for p in self.players])
|
_logs.log_debug(f'players: %s'% [(p.get_name(), p.get_coordinates()) for p in self.players])
|
||||||
print('##')
|
_logs.log_debug(f'items: %s' % [(i.get_name(), i.get_coordinates()) for i in self.items])
|
||||||
_logs.log_debug(f'items: %s' % [(p.get_name(), p.get_coordinates()) for p in self.items])
|
|
||||||
|
|
||||||
def populate_map(self):
|
def populate_map(self):
|
||||||
for player in self.players:
|
for player in self.players:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class BrSimItem(_resource.BrSimResource):
|
|||||||
# this decision would change everything from Arena init
|
# this decision would change everything from Arena init
|
||||||
|
|
||||||
def __init__(self, item_id):
|
def __init__(self, item_id):
|
||||||
|
super().__init__()
|
||||||
self.item= _isyms.ITEMS[item_id]
|
self.item= _isyms.ITEMS[item_id]
|
||||||
|
|
||||||
def is_item(self):
|
def is_item(self):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from utils import logs as _logs
|
|||||||
class BrSimPlayer(_resource.BrSimResource):
|
class BrSimPlayer(_resource.BrSimResource):
|
||||||
|
|
||||||
def __init__(self, name, inventory= None):
|
def __init__(self, name, inventory= None):
|
||||||
super()
|
super().__init__()
|
||||||
self.id= str(_uuid.uuid4())
|
self.id= str(_uuid.uuid4())
|
||||||
self.name= name
|
self.name= name
|
||||||
self.stats= ''
|
self.stats= ''
|
||||||
|
|||||||
Reference in New Issue
Block a user