2025-07-24 22:36:36 +02:00
import time as _time
import random as _rand
import main as _main
2025-07-25 23:41:44 +02:00
def _debug_data ( ) :
2025-07-24 22:36:36 +02:00
players = [
{
' name ' : ' Elara ' ,
} ,
{
' name ' : ' Kaelen ' ,
} ,
{
' name ' : ' Zephyr ' ,
2025-07-24 23:07:33 +02:00
} ,
{
' name ' : ' Lyra ' ,
} ,
{
' name ' : ' Orion ' ,
} ,
{
' name ' : ' Seraphina ' ,
} ,
2025-07-24 22:36:36 +02:00
]
2025-07-24 22:58:46 +02:00
weapons = [ ]
2025-07-24 22:36:36 +02:00
Arena = _main . init_arena ( players , weapons )
print ( f ' Players: { Arena . get_players ( ) } ' )
print ( f ' Weapons: { Arena . get_weapons ( ) } ' )
2025-07-25 23:41:44 +02:00
return Arena
def _end_game_debug ( alive_players , day ) :
last_player = alive_players [ 0 ]
2025-07-26 00:06:29 +02:00
msg = f ' { last_player . get_name ( ) } sopravvive e vince dopo { day } lunghi Giorni, conquistando l \' amore eterno di Guarino '
print ( msg )
return msg
2025-07-25 23:41:44 +02:00
2025-08-01 21:42:48 +02:00
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 ( ) )
2025-08-01 22:30:41 +02:00
msg = f ' { Player_one . get_name ( ) } Si muove verso »»» { direction } '
2025-08-01 21:42:48 +02:00
return msg
2025-07-25 23:41:44 +02:00
def play_one_day_debug ( Arena ) :
if not Arena . get_players ( ) : return
2025-07-26 12:52:55 +02:00
print ( f ' Giorno # { Arena . day } ' )
alive_players = Arena . get_alive_players ( )
2025-07-25 23:41:44 +02:00
if len ( alive_players ) == 1 :
day = Arena . day
return _end_game_debug ( alive_players , day )
2025-07-26 12:52:55 +02:00
daily_events = [ ]
_rand . shuffle ( alive_players )
2025-08-01 21:42:48 +02:00
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)
2025-07-26 12:52:55 +02:00
daily_events . append ( msg )
2025-07-25 23:41:44 +02:00
Arena . next_day ( )
2025-07-26 12:52:55 +02:00
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
2025-07-25 23:41:44 +02:00
def init_debug_loop ( ) :
Arena = _debug_data ( )
2025-07-24 22:36:36 +02:00
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
2025-07-24 22:58:46 +02:00
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 ' )
2025-07-28 20:08:15 +02:00
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 )
2025-07-24 22:36:36 +02:00
if __name__ == ' __main__ ' :
init_debug ( )