forked from Cryz/battle_royale_sim
118 lines
3.4 KiB
Python
118 lines
3.4 KiB
Python
import time as _time
|
|
import random as _rand
|
|
import main as _main
|
|
|
|
def _debug_data():
|
|
players= [
|
|
{
|
|
'name': 'Elara',
|
|
},
|
|
{
|
|
'name': 'Kaelen',
|
|
},
|
|
{
|
|
'name': 'Zephyr',
|
|
},
|
|
{
|
|
'name': 'Lyra',
|
|
},
|
|
{
|
|
'name': 'Orion',
|
|
},
|
|
{
|
|
'name': 'Seraphina',
|
|
},
|
|
]
|
|
weapons= []
|
|
|
|
Arena= _main.init_arena(players, weapons)
|
|
print(f'Players: {Arena.get_players()}')
|
|
print(f'Weapons: {Arena.get_weapons()}')
|
|
return Arena
|
|
|
|
def _end_game_debug(alive_players, day):
|
|
last_player= alive_players[0]
|
|
msg= f'{last_player.get_name()} sopravvive e vince dopo {day} lunghi Giorni, conquistando l\'amore eterno di Guarino'
|
|
print(msg)
|
|
return msg
|
|
|
|
def _random_action(Arena, Player_one):
|
|
_RANDOM_ACTIONS= {
|
|
1: 'attack',
|
|
2: 'move',
|
|
}
|
|
action= _rand.randint(1, len(_RANDOM_ACTIONS))
|
|
msg= ''
|
|
if action == 1:
|
|
# XXX maybe in future this action is available only if you are near to another player
|
|
# so Player_two is no more random, but will be a random near player
|
|
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
|
while Player_one.get_id() == Player_two.get_id():
|
|
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
|
_dmg, msg= Player_one.attack(Player_two)
|
|
elif action == 2:
|
|
Map= Arena.get_map()
|
|
available_movements= Map.get_player_available_directions(Player_one)
|
|
if not available_movements: return f'{Player_one.get_name()} Pensa a Guarino tutto il giorno' # XXX probably should skip this action and look for another action
|
|
_rand.shuffle(available_movements)
|
|
x, y, direction= available_movements[0]
|
|
Player_one.move(x, y)
|
|
Map.init_map_matrix()
|
|
print(Map.get_renderized_map())
|
|
msg= f'{Player_one.get_name()} Si muove a: {direction}'
|
|
|
|
return msg
|
|
|
|
def play_one_day_debug(Arena):
|
|
if not Arena.get_players(): return
|
|
print(f'Giorno #{Arena.day}')
|
|
alive_players= Arena.get_alive_players()
|
|
if len(alive_players) == 1:
|
|
day= Arena.day
|
|
return _end_game_debug(alive_players, day)
|
|
|
|
daily_events= []
|
|
_rand.shuffle(alive_players)
|
|
for Player_one in alive_players:
|
|
if not Player_one.is_alive(): continue # he could be dead during this day cycle
|
|
msg= _random_action(Arena, Player_one)
|
|
#p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
|
#while Player_one.get_id() == p_two.get_id():
|
|
#p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
|
#_dmg, msg= Player_one.attack(p_two)
|
|
daily_events.append(msg)
|
|
|
|
Arena.next_day()
|
|
res= '\n'.join(daily_events)
|
|
return res
|
|
#p_one, p_two= _rand.sample(alive_players, 2)
|
|
#_dmg, msg= p_one.attack(p_two)
|
|
#return msg
|
|
|
|
def init_debug_loop():
|
|
Arena= _debug_data()
|
|
while (len(Arena.get_alive_players()) > 1):
|
|
alive_players= Arena.get_alive_players()
|
|
|
|
p_one, p_two= _rand.sample(alive_players, 2)
|
|
p_one.attack(p_two)
|
|
|
|
#Start a day
|
|
#At 23:59:
|
|
Arena.next_day()
|
|
_time.sleep(0.3)
|
|
#End of day
|
|
|
|
last_player= Arena.get_alive_players()[0]
|
|
print(f'{last_player.get_name()} sopravvive e vince dopo {Arena.day} lunghi Giorni, conquistando l\'amore eterno di Guarino')
|
|
|
|
def debug_random_map():
|
|
from entities import map as _map;
|
|
from entities import player;
|
|
M= _map.BrSimMap(players= [player.BrSimPlayer(i) for i in range(20)]);
|
|
res= M.get_renderized_map()
|
|
print(res)
|
|
|
|
if __name__ == '__main__':
|
|
init_debug()
|