diff --git a/backup b/backup deleted file mode 100644 index e69de29..0000000 diff --git a/skill_generator.py b/skill_generator.py index 97e5c39..964aaec 100755 --- a/skill_generator.py +++ b/skill_generator.py @@ -78,7 +78,6 @@ list.append(['replace','Des de substitution',1,'int','L',0,-1,"",None]) list.append(['add_to_all','Valeur d\'ajout aux des',1,'int','l',0,0,"",None]) list.append(['max_dices','Nombre de des max',1,'pint','m',0,-1,"",None]) list.append(['player_name','Nom du joueur',1,'str',':',0,'""',"",None]) -list.append(['crit_level','Niveau de critique',1,'pint','u',0,0,"",None]) list.append(['nb_dices','Nombre de des',1,'pint','',0,0,"",None]) list.append(['nb_flat_dices','Nombre de des fixes',1,'pint','',0,0,"",None]) @@ -228,6 +227,34 @@ def reroll(args): return reroll +def find_code(args): + "Find the next available code for given name" + try: + code=args[1] + except: + print("One argument expected") + return 0 + listFree='' + for letter in code: + Letter=letter.capitalize() + free,Free=1,1 + for line in wrapper: + if free and letter==line.code: + free=0 + if Free and Letter==line.code: + Free=0 + if not free and not Free: + break + if Free and Letter not in listFree: + listFree+=Letter + if free and letter not in listFree: + listFree+=letter + if listFree: + return 'The codes "{}" are available.'.format(listFree) + else: + print('No letter from name "{}" is available'.format(code)) + print(find_code([0,"abcdefghijklmnopqrstuvwxyz&_?.ยง!;"])) + def parser(args): "Generate the argument parser" tab=" " @@ -286,17 +313,14 @@ class testInit(minitest.simpleTestUnit): def _testInit(self): self.currentTest("generating test values") - try: - test_values=args[1] - except: - self.addWarning("No arguments given, using defaults",nonDestructive=True) - test_values={"nb_dices":0,"perfection":0,"defense_i_0":0,"defense_i_1":0, - "defense_i_2":0,"rempart_p":0,"technique_m":0,"coup_d":0,"coup_d_results":"[]", - "fauchage":0,"exploiter_p_0":0,"exploiter_p_1":0,"exploiter_p_2":0,"tir_p_0":0, - "tir_p_1":0,"tir_i":0,"charge":0,"charge_i":0,"nb_2add":0,"nb_2sub":0,"relances":0, - "seuil":0,"nb_flat_dices":0,"action":'""',"flat_dices":"[]","results":"[]","technique_result":0, - "cleave":"[]","on_hit_c":0,"attribute":0,"encaissement":0,"encaissement_dices":'""', - "encaissement_result":0,"replace":-1,"add_to_all":0,"max_dices":-1,"player_name":'""'} + + test_values={"nb_dices":0,"perfection":0,"defense_i_0":0,"defense_i_1":0, + "defense_i_2":0,"rempart_p":0,"technique_m":0,"coup_d":0,"coup_d_results":"[]", + "fauchage":0,"exploiter_p_0":0,"exploiter_p_1":0,"exploiter_p_2":0,"tir_p_0":0, + "tir_p_1":0,"tir_i":0,"charge":0,"charge_i":0,"nb_2add":0,"nb_2sub":0,"relances":0, + "seuil":0,"nb_flat_dices":0,"action":'""',"flat_dices":"[]","results":"[]","technique_result":0, + "cleave":"[]","on_hit_c":0,"attribute":0,"encaissement":0,"encaissement_dices":'""', + "encaissement_result":0,"replace":-1,"add_to_all":0,"max_dices":-1,"player_name":'""'} a=len(test_values) b=len(list) try: @@ -309,12 +333,11 @@ class testInit(minitest.simpleTestUnit): self.currentTest("testing list") if a1: + sub=[]# A list of test to execute + for a in args[1:]: + a=a.strip("-") + if a in all_s or a=="all": + t+=1 + sub.append(a.strip("-")) + else: + print("Argument {} unknown".format(a)) + else: + sub=all_s + t=len(sub) + + if "all" in sub or "reroll" in sub: + #"Check the reroll inline generation" + subclass.addTest(testReroll()) + if "all" in sub or "init" in sub: + #"Check the initialisation message" + subclass.addTest(testInit()) + if "all" in sub or "wrapper" in sub: + #"Test the wrapper, only useful internally" + subclass.addTest(testWrapper()) + if "all" in sub or "parser" in sub: + #"Check the reroll inline generation" + subclass.addTest(testParser()) + + + if t>0: + subclass.test() + status=subclass.get_status() + return status['failure'] + return 0 def help(args): "Help, print the following message" @@ -527,8 +550,7 @@ def help(args): print(" {}: {}".format(key,commands[key].__doc__)) commands={"init":initialise,"print":pprint,"reroll":reroll, -"test_init":check_init,"test_wrapper":check_wrapper, -"test":test_all,"parser":parser,"help":help} +"test":test_all,"code":find_code,"parser":parser,"help":help} if __name__ == '__main__': wrapper=megaListWrapper()