@ -30,7 +30,7 @@ class Parser: #Pour parser la ligne de commande
self . _mtch = " "
self . _mtch = " "
self . _room = room
self . _room = room
self . _arg = { }
self . _arg = { }
self . _option = [ False , False , False , 0 , 0 , 0 , 0 , 0 , False , 0 ]
self . _option = [ False , False , False , 0 , 0 , 0 , 0 , 0 , False , 0 , 0 ]
@property
@property
def str ( self ) :
def str ( self ) :
@ -130,7 +130,19 @@ def help(room, event):
args . pop ( 0 )
args . pop ( 0 )
if ( len ( args ) > 0 ) :
if ( len ( args ) > 0 ) :
if ( re . search ( " roll " , args [ 0 ] ) ) :
if ( re . search ( " roll " , args [ 0 ] ) ) :
room . send_text ( " :roll <options> <des> (+-modifs ou des) \n \n - exemple :roll vr4g3 6d6 - \ #g \ #r3d6 +2 x3 : lance avec les details 6d6 en relancant les des avec un resultat de 4+ et en gardant les trois meilleurs, puis en retranchant 3d6 sans relancer les 4+ et en gardant tout, enfin ajouter 2. L ' operation sera executee trois fois. \n \n - v : details (verbose) du jet \n - n : no add, chaque de est traite separement \n - e : explosif, si un de fait le maximum, on le relance et on additionne \n - f<nb> : difficulte a atteindre par de avec option n \n - g<nb> : nombre de des conserves \n - r<nb> : relance si le de a obtenu au moins ce nombre \n - s<nb/nb> : seuil a atteindre et niveaux de reussites \n - w<nb> : lance un wild die avec les autres. " )
room . send_text ( " :roll <options> <des> (+-modifs ou des) \n \n - exemple :roll vr4g3 6d6 - \ #g \ #r3d6 +2 x3 : lance avec les details 6d6 en relancant les des avec un resultat de 4+ et en gardant les trois meilleurs, puis en retranchant 3d6 sans relancer les 4+ et en gardant tout, enfin ajouter 2. L ' operation sera executee trois fois. \n \n - v : details (verbose) du jet \n - n : no add, chaque de est traite separement \n - e : explosif, si un de fait le maximum, on le relance et on additionne \n - f<nb> : difficulte a atteindre par de avec option n \n - g<nb> : nombre de des conserves \n - r<nb> : relance si le de a obtenu au moins ce nombre \n - m<nb> : Enleve un succes si ce nombre ou moins est atteint \n - s<nb/nb> : seuil a atteindre et niveaux de reussites \n - w<nb> : lance un wild die avec les autres. " )
elif ( re . search ( " sw " , args [ 0 ] ) ) :
room . send_text ( " - :sw <options> <des> : Lance les des en mode Savage Worlds \n Verbose/Noadd/Explosif/Seuil 4/Niveau de reussite 4/Wild Die d6. " )
elif ( re . search ( " dom " , args [ 0 ] ) ) :
room . send_text ( " - :dom <options> <des> : Lance les dommages en mode Savage Worlds \n Verbose/Explosif/seuil 4/Niveau de reussite 4. " )
elif ( re . search ( " wod " , args [ 0 ] ) ) :
room . send_text ( " - :wod <options> <des> : Lance les des en mode Nouveau Monde des Tenebres \n Verbose/Noadd/Difficulte 8/Relance les 10. " )
elif ( re . search ( " owod " , args [ 0 ] ) ) :
room . send_text ( " - :owod <options> <des> : Lance les des en mode Ancien Monde des Tenebres \n Verbose/Noadd/Difficulte 6/Relance les 10/Les 1 enleve un succes. " )
elif ( re . search ( " ars " , args [ 0 ] ) ) :
room . send_text ( " - :ars <options> <des> : Lance les des en mode Ars Magicka : de de tension \n Verbose/Noadd/Sur un 1, on relance et on double. " )
elif ( re . search ( " des " , args [ 0 ] ) ) :
room . send_text ( " - :des <options> <des> : Lance des des de desastre \n Verbose/Noadd/Difficulte 10. " )
elif ( re . search ( " carte " , args [ 0 ] ) ) :
elif ( re . search ( " carte " , args [ 0 ] ) ) :
room . send_text ( " - !carte : Tire une carte et la retire du paquet \n - !carte m : remelange le paquet. " )
room . send_text ( " - !carte : Tire une carte et la retire du paquet \n - !carte m : remelange le paquet. " )
elif ( re . search ( " card " , args [ 0 ] ) ) :
elif ( re . search ( " card " , args [ 0 ] ) ) :
@ -138,12 +150,13 @@ def help(room, event):
else :
else :
room . send_text ( " A venir " )
room . send_text ( " A venir " )
else :
else :
room . send_text ( " Commandes disponibles: \n - !card \n - !carte \n - :roll <options> <des> \n - !help <commande> " )
room . send_text ( " Commandes disponibles: \n - !card \n - !carte \n - :roll <options> <des> \n - :sw <options> <des> \n - :dom <options> <des> \n - :wod <options> <des> \n - :owod <options> <des> \n - :ars <options> <des> \n - :des <options> <des> \n - !help <commande> " )
def roll ( result , type , explosif , nb , f , noadd , ars , relance ) :
def roll ( result , type , explosif , nb , f , noadd , ars , relance , mitige ) :
# verif type et contenu params?
# verif type et contenu params?
roll = 0
roll = 0
new = 0
new = 0
moins = 0
if ( ars ) :
if ( ars ) :
roll = 1
roll = 1
if ( type > 1 ) :
if ( type > 1 ) :
@ -161,16 +174,18 @@ def roll(result,type,explosif,nb,f,noadd,ars,relance):
roll + = int ( tmp )
roll + = int ( tmp )
if ( relance != 0 and relance != 1 and relance < = roll ) :
if ( relance != 0 and relance != 1 and relance < = roll ) :
new = 1
new = 1
if ( mitige != 0 and mitige > = roll ) :
moins = 1
result + = ( ' ' if nb > 0 else ' ' ) + str ( roll )
result + = ( ' ' if nb > 0 else ' ' ) + str ( roll )
if ( f != 0 and roll < f ) :
if ( f != 0 and roll < f ) :
roll = 0
roll = 0
elif ( f != 0 and roll > = f and noadd ) :
elif ( f != 0 and roll > = f and noadd ) :
tmp = int ( roll / / type )
tmp = int ( roll / / type )
roll = tmp + ( ( roll - tmp * type ) > = 1 if f else 0 )
roll = tmp + ( ( roll - tmp * type ) > = 1 if f else 0 ) - moins
#print("fin roll " + str(result) + " " + str(roll) + " " + str(new))
#print("fin roll " + str(result) + " " + str(roll) + " " + str(new))
return ( result , roll , new )
return ( result , roll , new )
def rolls ( result , jet , type , nb , explosif , noadd , wild , f , g , ars , relance ) :
def rolls ( result , jet , type , nb , explosif , noadd , wild , f , g , ars , relance , mitige ) :
total = 0
total = 0
allresult = [ ]
allresult = [ ]
tmp = ( type and nb )
tmp = ( type and nb )
@ -179,14 +194,14 @@ def rolls(result,jet,type,nb,explosif,noadd,wild,f,g,ars,relance):
#print(jet)
#print(jet)
for _ in range ( nb ) :
for _ in range ( nb ) :
new = 0
new = 0
result , res1 , new = roll ( result , type , explosif , nb , f , noadd , ars , relance )
result , res1 , new = roll ( result , type , explosif , nb , f , noadd , ars , relance , mitige )
allresult . append ( res1 )
allresult . append ( res1 )
while ( new == 1 ) :
while ( new == 1 ) :
result , res1 , new = roll ( result , type , explosif , nb , f , noadd , ars , relance )
result , res1 , new = roll ( result , type , explosif , nb , f , noadd , ars , relance , mitige )
allresult . append ( res1 )
allresult . append ( res1 )
if ( wild != 0 ) :
if ( wild != 0 ) :
jet + = " w " + str ( wild )
jet + = " w " + str ( wild )
result , res1 , new = roll ( result , wild , wild != 1 , nb if nb else 0 , f , noadd , ars , relance )
result , res1 , new = roll ( result , wild , wild != 1 , nb if nb else 0 , f , noadd , ars , relance , mitige )
allresult . append ( res1 )
allresult . append ( res1 )
result + = ' w '
result + = ' w '
#print(allresult)
#print(allresult)
@ -200,6 +215,7 @@ def rolls(result,jet,type,nb,explosif,noadd,wild,f,g,ars,relance):
jet + = ( ( " g " + str ( g ) ) if g != 0 else " #g " ) if g != parser . option [ 5 ] else ( ( " g " + str ( g ) ) if g != 0 else " " )
jet + = ( ( " g " + str ( g ) ) if g != 0 else " #g " ) if g != parser . option [ 5 ] else ( ( " g " + str ( g ) ) if g != 0 else " " )
jet + = ( ( " f " + str ( f ) ) if f != 0 else " #f " ) if f != parser . option [ 4 ] else ( ( " f " + str ( f ) ) if f != 0 else " " )
jet + = ( ( " f " + str ( f ) ) if f != 0 else " #f " ) if f != parser . option [ 4 ] else ( ( " f " + str ( f ) ) if f != 0 else " " )
jet + = ( ( " r " + str ( relance ) ) if relance != 0 else " #r " ) if relance != parser . option [ 9 ] else ( ( " r " + str ( relance ) ) if relance != 0 else " " )
jet + = ( ( " r " + str ( relance ) ) if relance != 0 else " #r " ) if relance != parser . option [ 9 ] else ( ( " r " + str ( relance ) ) if relance != 0 else " " )
jet + = ( ( " m " + str ( mitige ) ) if mitige != 0 else " #m " ) if mitige != parser . option [ 9 ] else ( ( " m " + str ( mitige ) ) if mitige != 0 else " " )
if ( tmp ) :
if ( tmp ) :
jet + = ( " e " if explosif == True else " #e " ) if explosif != parser . option [ 0 ] else " "
jet + = ( " e " if explosif == True else " #e " ) if explosif != parser . option [ 0 ] else " "
jet + = ( " n " if noadd == True else " #n " ) if noadd != parser . option [ 1 ] else " "
jet + = ( " n " if noadd == True else " #n " ) if noadd != parser . option [ 1 ] else " "
@ -221,22 +237,25 @@ def entryPoint(room, event):
print ( text )
print ( text )
if ( parser . eat ( " :roll " , 1 ) ) :
if ( parser . eat ( " :roll " , 1 ) ) :
parser . option = [ False , False , False , 0 , 0 , 0 , 0 , 0 , False , 0 ]
parser . option = [ False , False , False , 0 , 0 , 0 , 0 , 0 , False , 0 , 0 ]
rollXPoint ( )
rollXPoint ( )
elif ( parser . eat ( " :dom " , 1 ) ) :
elif ( parser . eat ( " :dom " , 1 ) ) :
parser . option = [ True , False , True , 0 , 0 , 0 , 4 , 4 , False , 0 ]
parser . option = [ True , False , True , 0 , 0 , 0 , 4 , 4 , False , 0 , 0 ]
rollXPoint ( )
rollXPoint ( )
elif ( parser . eat ( " :sw " , 1 ) ) :
elif ( parser . eat ( " :sw " , 1 ) ) :
parser . option = [ True , True , True , 0 , 0 , 0 , 4 , 4 , False , 0 ]
parser . option = [ True , True , True , 0 , 0 , 0 , 4 , 4 , False , 0 , 0 ]
rollXPoint ( )
rollXPoint ( )
elif ( parser . eat ( " :ars " , 1 ) ) :
elif ( parser . eat ( " :ars " , 1 ) ) :
parser . option = [ False , True , True , 0 , 0 , 0 , 0 , 0 , True , 0 ]
parser . option = [ False , True , True , 0 , 0 , 0 , 0 , 0 , True , 0 , 0 ]
rollXPoint ( )
rollXPoint ( )
elif ( parser . eat ( " :des " , 1 ) ) :
elif ( parser . eat ( " :des " , 1 ) ) :
parser . option = [ False , True , True , 0 , 10 , 0 , 0 , 0 , False , 0 ]
parser . option = [ False , True , True , 0 , 10 , 0 , 0 , 0 , False , 0 , 0 ]
rollXPoint ( )
rollXPoint ( )
elif ( parser . eat ( " :wod " , 1 ) ) :
elif ( parser . eat ( " :wod " , 1 ) ) :
parser . option = [ False , True , True , 0 , 8 , 0 , 0 , 0 , False , 10 ]
parser . option = [ False , True , True , 0 , 8 , 0 , 0 , 0 , False , 10 , 0 ]
rollXPoint ( )
elif ( parser . eat ( " :owod " , 1 ) ) :
parser . option = [ False , True , True , 0 , 6 , 0 , 0 , 0 , False , 10 , 1 ]
rollXPoint ( )
rollXPoint ( )
else :
else :
parser . arg [ " error " ] = True
parser . arg [ " error " ] = True
@ -320,6 +339,15 @@ def rollOptionPoint():
parser . option [ 9 ] = 10
parser . option [ 9 ] = 10
elif ( parser . eat ( " #[Rr] " , 1 ) ) :
elif ( parser . eat ( " #[Rr] " , 1 ) ) :
parser . option [ 9 ] = 0
parser . option [ 9 ] = 0
elif ( parser . eat ( " [Mm] " , 1 ) ) :
if ( parser . space ( ) ) :
parser . option [ 10 ] = 1
elif ( parser . eat ( r " \ d+ " , 1 ) ) :
parser . option [ 10 ] = int ( parser . mtch )
else :
parser . option [ 10 ] = 1
elif ( parser . eat ( " #[Mm] " , 1 ) ) :
parser . option [ 10 ] = 0
else :
else :
break
break
@ -327,7 +355,7 @@ def dupli(orig):
salon = orig . room
salon = orig . room
orig . room = None
orig . room = None
nouv = copy . deepcopy ( orig )
nouv = copy . deepcopy ( orig )
nouv . option = [ orig . option [ 0 ] , orig . option [ 1 ] , orig . option [ 2 ] , orig . option [ 3 ] , orig . option [ 4 ] , orig . option [ 5 ] , orig . option [ 6 ] , orig . option [ 7 ] , orig . option [ 8 ] , orig . option [ 9 ] ]
nouv . option = [ orig . option [ 0 ] , orig . option [ 1 ] , orig . option [ 2 ] , orig . option [ 3 ] , orig . option [ 4 ] , orig . option [ 5 ] , orig . option [ 6 ] , orig . option [ 7 ] , orig . option [ 8 ] , orig . option [ 9 ] , orig . option [ 10 ] ]
orig . room = salon
orig . room = salon
nouv . room = salon
nouv . room = salon
return nouv
return nouv
@ -361,7 +389,7 @@ def rollPlusMoinsPoint():
jet = " "
jet = " "
rollOptionPoint ( )
rollOptionPoint ( )
#print(parser.option)
#print(parser.option)
exp , noa , ver , will , f , g , s , d , ars , r = parser . option
exp , noa , ver , will , f , g , s , d , ars , r , m = parser . option
rollEntityPoint ( )
rollEntityPoint ( )
#print("de " + str(parser.arg.get("roll_nb",None)) + "|" + str(parser.arg.get("roll_typ",None)))
#print("de " + str(parser.arg.get("roll_nb",None)) + "|" + str(parser.arg.get("roll_typ",None)))
if ( not parser . arg [ " error " ] ) :
if ( not parser . arg [ " error " ] ) :
@ -370,9 +398,9 @@ def rollPlusMoinsPoint():
result + = " - "
result + = " - "
if ( parser . arg . get ( " roll_typ " , None ) or parser . arg . get ( " roll_wil " , None ) ) :
if ( parser . arg . get ( " roll_typ " , None ) or parser . arg . get ( " roll_wil " , None ) ) :
result + = " ( "
result + = " ( "
exp2 , noa2 , ver2 , will2 , f2 , g2 , s2 , d2 , ars2 , r2 = parser . option
exp2 , noa2 , ver2 , will2 , f2 , g2 , s2 , d2 , ars2 , r2 , m2 = parser . option
parser . option = [ exp , noa , ver , will , f , g , s , d , ars , r ]
parser . option = [ exp , noa , ver , will , f , g , s , d , ars , r , m ]
result , res1 , jet = rolls ( result , jet , parser . arg . get ( " roll_typ " , None ) , parser . arg . get ( " roll_nb " , None ) , exp2 , noa2 , will2 , f2 , g2 , ars2 , r2 )
result , res1 , jet = rolls ( result , jet , parser . arg . get ( " roll_typ " , None ) , parser . arg . get ( " roll_nb " , None ) , exp2 , noa2 , will2 , f2 , g2 , ars2 , r2 , m2 )
result + = " = " + str ( res1 ) + " ) "
result + = " = " + str ( res1 ) + " ) "
else :
else :
jet + = str ( parser . arg . get ( " roll_nb " , None ) )
jet + = str ( parser . arg . get ( " roll_nb " , None ) )
@ -391,9 +419,9 @@ def rollPlusMoinsPoint():
result + = " + " if parser . arg . get ( " roll_sig " , True ) else " - "
result + = " + " if parser . arg . get ( " roll_sig " , True ) else " - "
if ( parser . arg . get ( " roll_typ " , None ) or parser . arg . get ( " roll_wil " , None ) ) :
if ( parser . arg . get ( " roll_typ " , None ) or parser . arg . get ( " roll_wil " , None ) ) :
result + = " ( "
result + = " ( "
exp2 , noa2 , ver2 , will2 , f2 , g2 , s2 , d2 , ars2 , r2 = parser . option
exp2 , noa2 , ver2 , will2 , f2 , g2 , s2 , d2 , ars2 , r2 , m2 = parser . option
parser . option = [ exp , noa , ver , will , f , g , s , d , ars , r ]
parser . option = [ exp , noa , ver , will , f , g , s , d , ars , r , m ]
result , res2 , jet = rolls ( result , jet , parser . arg . get ( " roll_typ " , None ) , parser . arg . get ( " roll_nb " , None ) , exp2 , noa2 , will2 , f2 , g2 , ars2 , r2 )
result , res2 , jet = rolls ( result , jet , parser . arg . get ( " roll_typ " , None ) , parser . arg . get ( " roll_nb " , None ) , exp2 , noa2 , will2 , f2 , g2 , ars2 , r2 , m2 )
result + = " = " + str ( res2 ) + " ) "
result + = " = " + str ( res2 ) + " ) "
else :
else :
jet + = str ( parser . arg . get ( " roll_nb " , None ) )
jet + = str ( parser . arg . get ( " roll_nb " , None ) )