Compare commits

...

21 Commits
master ... vky

Author SHA1 Message Date
vkyfox 7813de6a80 Text adjustments for French langugage 2021-12-02 21:24:36 +01:00
Maximilien Rigaut 86335f4ec7 Some spellchecks 2021-12-02 20:20:15 +01:00
Maximilien Rigaut 17ac2dec13 Cleanup 2021-12-02 19:01:17 +01:00
Maximilien Rigaut 868fa87edb Generator shitshow 2021-12-01 19:54:21 +01:00
Maximilien Rigaut b0edc9c58a Actual correction of superskill 2021-04-14 00:37:27 +02:00
Maximilien Rigaut 6516c98335 Added Subskills 2021-03-31 08:11:48 +02:00
Maximilien Rigaut df97d0e56f Full automatism on customs 2021-03-31 07:56:42 +02:00
Maximilien Rigaut 742e0938c8 Tryout of full auto gen 2021-03-31 07:40:22 +02:00
Maximilien Rigaut f53fe21faf Consumables 2021-03-21 04:39:17 +01:00
Maximilien Rigaut 5eae4f0914 Added Munitions Solides 2021-03-20 21:11:06 +01:00
Maximilien Rigaut d291508726 Working Ammory 2021-03-20 08:06:20 +01:00
Maximilien Rigaut a7c3dc77e3 Semi Functional Weaponry 2021-03-20 07:42:33 +01:00
Maximilien Rigaut d5bd131422 Bit fixup 2020-02-02 22:14:48 +01:00
Maximilien Rigaut 16d43aef12 Purged the non-cyberpunk 2020-01-31 19:16:13 +01:00
Maximilien Rigaut 8c3fac5cea Couple cosmetic changes 2020-01-24 00:58:13 +01:00
Maximilien Rigaut 2840646473 Fixed the gen
At last
2020-01-24 00:34:32 +01:00
Maximilien Rigaut 9f298f8298 Movearound 2020-01-23 21:40:15 +01:00
Maximilien Rigaut 97bbea1bef Starting to implement gen 2020-01-23 21:38:45 +01:00
Dandaedre ee51947439 Huge refactor of the generator 2020-01-22 18:35:55 +01:00
Maximilien Rigaut d386201c40 ugly gen 2020-01-21 21:43:39 +01:00
Dandaedre ed4498884b Started the generation process 2020-01-19 08:12:00 +01:00
19 changed files with 6060 additions and 1614 deletions

5
.gitignore vendored
View File

@ -110,3 +110,8 @@ venv.bak/
.mypy_cache/ .mypy_cache/
.dmypy.json .dmypy.json
dmypy.json dmypy.json
.idea/vcs.xml
.idea/sys_d10.iml
.idea/modules.xml
.idea/misc.xml
.idea/inspectionProfiles/profiles_settings.xml

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "minitest"] [submodule "minitest"]
path = minitest path = helpers/minitest
url = git@github.com:Malphaet/minitest.git url = git@github.com:Malphaet/minitest.git

View File

@ -1,61 +0,0 @@
General
Initiative (Comp)
Rapidite_surnaturelle @Actions
Frères_d'arme @Reserve
Perfection P
Prescience_ @Reserve
Rage_primale @Reserve
A_corps_perdu @Reserve
undescored_name :
Defence
Encaissement @Defence
Encaissement @Defence
Resistances @Defence
Endurance_surnaturelle @PV
Riposte @Reserve
Riposte @Reserve
Parade @Reserve
Defense_impenetrable I_1
Defense_impenetrable I_2
Defense_impenetrable I_4
Rempart_parfait R
Infatigable (Rappel)
Dernier_Souffle_ (Rappel)
Envers_et_contre_tout (Rappel)
Regeneration (Rappel)
Regeneration (Rappel)
Presence_ecrasante (Rappel)
Maîtrise_du_combat (Rappel)
Offense
Technique_martiale M_1
Technique_martiale M_2
Coup_en_Puissance @Reserve
Coup_Double @Reserve
Coup_dechirant D
Fauchage F
Coup_mortel (Rappel)@Reserve
Combat_acrobatique (Rappel)
Assaut_implacable (Rappel)
Tir_en_mouvement (Rappel)
Exploiter_les_points_faibles E_1
Exploiter_les_points_faibles E_2
Exploiter_les_points_faibles E_4
Double_initiative (Rappel)**
Marcher_dans_les_ombres (Rappel)
Rage_Berserk (Rappel)**
Influx_meurtrier (Rappel)**
Special
Tir_mortel @Reserve
Tir_precis T_1
Tir_precis T_2
replace L
add_to_add l
Tir_implacable i
Charge C
Charge_Mortelle (Rappel)
Charge_indomptable N

View File

@ -1,93 +0,0 @@
//Variables a initialiser par parse
/*
var nb_dices=0;
Action a a e d
var all_dices d*
var nb_2add=0; //+
var nb_2sub=0; //-
var relances=0; //r
Perfection P
Defense
Défense_impénétrable I 1
Défense_impénétrable I 2 - Rappel
Défense_impénétrable I 4
Rempart_parfait R
Offense
Technique_martiale M 1
Technique_martiale M 2
Coup_déchirant D
Fauchage F
Exploiter_les_points_faibles E 1
Exploiter_les_points_faibles E 2 - Rappel
Exploiter_les_points_faibles E 4
Spécial
Tir_précis T 1
Tir_précis T 2
Tir_implacable i
Charge C
Charge_indomptable N - (Sur la feuille de perso)
Seuil s
On Hit crit H
Attribute values A
Encaissement S
*/
// SKILLNAME
on("change:skill_SKILLNAME_activation change:general_skilllevel_SKILLNAME", function() {
getAttrs(["skill_SKILLNAME_activation", "general_skilllevel_SKILLNAME"], function(values) {
setAttrs({"general_effective_SKILLNAME":values.skill_SKILLNAME_activation*values.general_skilllevel_SKILLNAME});
});
});
<!--SKILLNAME -->
<input class="sheet-skill_name" style="margin-right: 4px;" type="text" name="attr_general_skill_SKILLNAME" disabled="true" value="SKILLNAME" title="Nom de la compétence" />
<input type="number" min="0" value= "0" name="attr_skillcost_SKILLNAME" title="Coût de la compétence"/>
<input class="sheet-skill_name" value= "0" style="margin-right: 4px;" type="number" min="0" max="10" name="attr_general_skilllevel_SKILLNAME" title="Niveau dans la compétence" />
<select class="sheet-skill_select" style="margin-right:4px" name="attr_Skill_general_attribute_select_SKILLNAME"><option value="@{base-Force} + @{exal-Force}">For</option><option value="@{base-Agilite} + @{exal-Agilite}">Agi</option><option value="@{base-Perception} + @{exal-Perception}">Per</option><option value="@{base-Charisme} + @{exal-Charisme}">Cha</option><option value="@{base-Intelligence} + @{exal-Intelligence}">Int</option><option value="@{base-Perception} + @{exal-Perception}">Per</option><option value="@{base-Volonte} + @{exal-Volonte}">Vol</option><option value="@{base-Psyche} + @{exal-Psyche}">Psy</option><option value="@{base-Chance} + @{exal-Chance}">Chn</option></select>
<button type='roll' class="sheet-skillbutton" value="/e fait un jet de @{general_skill_SKILLNAME} [[(@{general_skilllevel_SKILLNAME}+(@{Skill_general_attribute_select_SKILLNAME}) - d@{dice})]] "></button>
<input type="checkbox" class="sheet-skill_activation" style="margin-right: 4px;" value="1" name="attr_skill_SKILLNAME_activation" />
<input class="sheet-skill_hidden" value= "0" type="number" name="attr_general_effective_SKILLNAME"/>
<!--FIELD_TYPE -->
<fieldset class="repeating_FIELD_TYPE-skills">
<input class="sheet-skill_name" type="text" name="attr_FIELD_TYPE_skillname" title="Nom de la compétence" />
<input type="number" name="attr_FIELD_TYPE_skillcost" title="Coût de la compétence" />
<input type="number" min="-10" max="10" name="attr_FIELD_TYPE_skilllevel" title="Niveau dans la compétence" />
<select class="sheet-skill_select" name="attr_FIELD_TYPE_attribute_select">
<option value="@{base-Force} + @{exal-Force}">For</option>
<option value="@{base-Agilite} + @{exal-Agilite}">Agi</option>
<option value="@{base-Perception} + @{exal-Perception}">Per</option>
<option value="@{base-Charisme} + @{exal-Charisme}">Cha</option>
<option value="@{base-Intelligence} + @{exal-Intelligence}">Int</option>
<option value="@{base-Perception} + @{exal-Perception}">Per</option>
<option value="@{base-Volonte} + @{exal-Volonte}">Vol</option>
<option value="@{base-Psyche} + @{exal-Psyche}">Psy</option>
<option value="@{base-Chance} + @{exal-Chance}">Chn</option>
</select>
<button type='roll' class="sheet-skillbutton" value="/e fait un jet de @{FIELD_TYPE_skillname} au d@{dice} [[@{FIELD_TYPE_skilllevel}+(@{FIELD_TYPE_attribute_select}) - d@{dice}]]"></button>
</fieldset>
<!--shield3 -->
<input class="sheet-skill_name" style="margin-right: 0px;" type="text" name="attr_general_item_shield3_name" value="shield3" />
<input class="sheet-skill_name" value="0" style="margin-right: 0px;" type="number" name="attr_general_item_shield3" title="Valeur de l'équipemet" />
<input type="checkbox" class="sheet-skill_activation" value="1" name="attr_item_shield3_activation" />
<input class="sheet-skill_hidden" value="0" type="number" name="attr_general_effective_shield3" />
// shield3
on("change:item_shield3_activation change:general_item_shield3", function() {
getAttrs(["item_shield3_activation", "general_item_shield3"], function(values) {
setAttrs({"general_effective_shield3":values.item_shield3_activation*values.general_item_shield3});
});
});
name roll_name dice_name result threshold
/e - Test d.+(\w*).*\[\[(.*)-.*\]\]
&{template:d10skillcheck}{{name=@{character_name}} {{roll_name=$1}} {{dice_name=@{dice}}} {{result=$2}} {{threshold=[[]]}}
/e .* @{(\w*)}.*\[(.*) -.*\)?\]\]
&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=@{$1}}} {{dice_name=@{dice}}} {{result=[[$2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[$2]]}}

View File

@ -235,7 +235,7 @@ function show_rolls(who,d_vars){
} else if (d_vars.action=="d"||d_vars.action=="e"){ } else if (d_vars.action=="d"||d_vars.action=="e"){
// Can't miss a block or a dodge, can be a shitty roll tho // Can't miss a block or a dodge, can be a shitty roll tho
} else { } else {
msg+="<tr><td class='sheet-sucess'>L'action est un succes (seuil "+d_vars.seuil+")</tr></td>"; msg+="<tr><td class='sheet-success'>L'action est un succes (seuil "+d_vars.seuil+")</tr></td>";
} }
} }
} else { } else {

File diff suppressed because it is too large Load Diff

580
helpers/base.py Normal file
View File

@ -0,0 +1,580 @@
head = """<head>
<link rel="stylesheet" type="text/css" href="systemd10cyberpunk.css"/>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/>
"""
script = "</head>" # The rest is kept for legacy reasons
"""" <script type="text/worker">
// Life_Points
// on("change:base-Force change:base-Agilite change:base-Volonte change:general_skilllevel_Endurance_surnaturelle", function() {
// getAttrs(["base-Force","base-Agilite","base-Volonte","general_skilllevel_Endurance_surnaturelle"], function(values) {
// setAttrs({"Life_Points_max":Number(values['base-Force'])+Number(values['base-Volonte'])+Number(values['base-Agilite'])+Number(values.general_skilllevel_Endurance_surnaturelle)*2+10});
// setAttrs({"Life_Points_maximum":Number(values['base-Force'])+Number(values['base-Volonte'])+Number(values['base-Agilite'])+Number(values.general_skilllevel_Endurance_surnaturelle)*2+10});
// });
// });
// Endurance_Points
on("change:base-Force change:base-Agilite change:general_skilllevel_Endurance_surnaturelle", function() {
getAttrs(["base-Force","base-Agilite","general_skilllevel_Endurance_surnaturelle"], function(values) {
setAttrs({"Endurance_Points_maximum":Number(values['base-Force'])*4});
setAttrs({"Endurance_Points_max":Number(values['base-Force'])*4});
});
});
// undescored_name
// on("change:character_name change:character_race", function() {
// getAttrs(["character_name"], function(values) {
// setAttrs({"undescored_name":values.character_name.replace(/ /g,"_").replace(/'/g,"/")});
// });
// });
// dice_with_tanscendance
</script>
</head>
"""
header = """
<div class="sheet-content">
<div class="sheet-center">
<input type="text" class="sheet-bigname" name="attr_character_name" placeholder="Nom"/>
<br/>
<input type="text" class="sheet-mediumname" name="attr_character_race" placeholder="Origine"/>
</div>
<br/>
<div class="sheet-2colrow">
<div class="sheet-col">
<table class="sheet-center sheet-black">
<tr>
<td><h3 class="sheet-center">Points de compétence :</h3></td>
<br/>
</tr>
<tr>
<td><input type="number" class="sheet-trait" name="attr_Character_points_spent" value="0"/> Utilisés</td>
<td rowspan="2">
<select class="sheet-dice_select sheet-dice" name="attr_dice">
<option value="2">d2</option>
<option value="4">d4</option>
<option value="6">d6</option>
<option value="8">d8</option>
<option value="10" selected>d10</option>
<option value="12">d12</option>
<option value="20">d20</option>
<option value="30">d30</option>
<option value="100">d100</option>
<option value="1000">d1000</option>
<option value="10000">d10000</option>
</select>
</td>
</tr>
<tr>
<td><input type="number" class="sheet-trait" name="attr_Character_points_unspent" value="0"/> Restants</td>
</tr>
</table>
</div>
</div>
<div class='sheet-2colrow'>
<div class='sheet-col'>
<h3 class="sheet-center">Caractéristiques</h3>
<div class="sheet-tab-content sheet-big_tab1">
<div class="sheet-tab-content sheet-big_tab2">
<table class="">
<tr>
<th>Carac</th>
<th>Valeur</th>
<th>Bonus</th>
<th colspan="2">Lancer</th>
</tr>
<tr>
<td>Force</td>
<td><input type="number" class="sheet-trait" name="attr_base-Force" title="Force de base" value="0" min="0" max="10" /></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Force" title="Modificateur" value="0" /></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Force}} {{dice_name=@{dice}}} {{result=[[(@{base-Force}+@{exal-Force})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Force}+@{exal-Force})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Force brute}} {{dice_name=@{dice}}} {{result=[[(@{base-Force}+@{exal-Force})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Force}+@{exal-Force})]]}}">Brut</button></td>
</tr>
<tr>
<td>Agilité</td>
<td><input type="number" class="sheet-trait" name="attr_base-Agilite" title="Agilité de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Agilite" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Agilité}} {{dice_name=@{dice}}} {{result=[[(@{base-Agilite}+@{exal-Agilite})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Agilite}+@{exal-Agilite})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Agilité}} {{dice_name=@{dice}}} {{result=[[(@{base-Agilite}+@{exal-Agilite})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Agilite}+@{exal-Agilite})]]}}">Brut</button></td>
</tr><tr>
<td>Perception</td>
<td><input type="number" class="sheet-trait" name="attr_base-Perception" title="Perception de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Perception" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Perception}} {{dice_name=@{dice}}} {{result=[[(@{base-Perception}+@{exal-Perception})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Perception}+@{exal-Perception})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Perception}} {{dice_name=@{dice}}} {{result=[[(@{base-Perception}+@{exal-Perception})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Perception}+@{exal-Perception})]]}}">Brut</button></td>
</tr><tr>
<td>Charisme</td>
<td><input type="number" class="sheet-trait" name="attr_base-Charisme" title="Charisme de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Charisme" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Charisme}} {{dice_name=@{dice}}} {{result=[[(@{base-Charisme}+@{exal-Charisme})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Charisme}+@{exal-Charisme})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Charisme}} {{dice_name=@{dice}}} {{result=[[(@{base-Charisme}+@{exal-Charisme})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Charisme}+@{exal-Charisme})]]}}">Brut</button></td>
</tr>
</table>
</div>
<div class='sheet-col'>
<h3 class="sheet-center">&nbsp;</h3>
<table class="">
<tr>
<th>Carac</th>
<th>Valeur</th>
<th>Bonus</th>
<th colspan="2">Lancer</th>
</tr>
<tr>
<td>Intelligence</td>
<td><input type="number" class="sheet-trait" name="attr_base-Intelligence" title="Intelligence de base" value="0" min="0" max="10" /></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Intelligence" title="Modificateur" value="0" /></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Intelligence}} {{dice_name=@{dice}}} {{result=[[(@{base-Intelligence}+@{exal-Intelligence})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Intelligence}+@{exal-Intelligence})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Intelligence brute}} {{dice_name=@{dice}}} {{result=[[(@{base-Intelligence}+@{exal-Intelligence})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Intelligence}+@{exal-Intelligence})]]}}">Brut</button></td>
</tr>
<tr>
<td>Volonté</td>
<td><input type="number" class="sheet-trait" name="attr_base-Volonte" title="Volonté de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Volonte" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Volonté}} {{dice_name=@{dice}}} {{result=[[(@{base-Volonte}+@{exal-Volonte})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Volonte}+@{exal-Volonte})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Volonté}} {{dice_name=@{dice}}} {{result=[[(@{base-Volonte}+@{exal-Volonte})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Volonte}+@{exal-Volonte})]]}}">Brut</button></td>
</tr><tr>
<td>Psyché</td>
<td><input type="number" class="sheet-trait" name="attr_base-Psyche" title="Psyché de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Psyche" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Psyché}} {{dice_name=@{dice}}} {{result=[[(@{base-Psyche}+@{exal-Psyche})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Psyche}+@{exal-Psyche})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Psyché}} {{dice_name=@{dice}}} {{result=[[(@{base-Psyche}+@{exal-Psyche})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Psyche}+@{exal-Psyche})]]}}">Brut</button></td>
</tr><tr>
<td>Chance</td>
<td><input type="number" class="sheet-trait" name="attr_base-Chance" title="Chance de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Chance" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Chance}} {{dice_name=@{dice}}} {{result=[[(@{base-Chance}+@{exal-Chance})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Chance}+@{exal-Chance})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Chance}} {{dice_name=@{dice}}} {{result=[[(@{base-Chance}+@{exal-Chance})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Chance}+@{exal-Chance})]]}}">Brut</button></td>
</tr>
</table>
</div>
</div>
<br/>
"""
footer = """
</div>
<rolltemplate class="sheet-rolltemplate-d10skillcheck">
<table class="">
<tr><th class="roll-title">{{name}} &mdash; {{roll_name}}</th></tr>
<tr><td class="roll-attr"> Test au d{{dice_name}} seuil {{threshold}} </td></tr>
<tr>
{{#rollWasCrit() result}}
<td class="roll-crit">Critique ! {{result}}<span class="inline fullcrit">x2</span> degrés de réussite</td>
{{/rollWasCrit() result}}
{{#^rollWasCrit() result}}
{{#rollWasFumble() result}}
{{#rollGreater() result 1}}
<td class="roll-fumble">Échec critique ! {{result}}<span class="inline fullfail">/2</span> degrés de réussite</td>
{{/rollGreater() result 1}}
{{#rollBetween() result 0 1}}
<td class="roll-fumble">Échec critique ! {{result}}<span class="inline fullfail">/2</span> degré de réussite</td>
{{/rollBetween() result 0 1}}
{{#rollLess() result 0}}
<td class="roll-fumble">Échec critique ! {{result}}<span class="inline fullfail">x2</span> degrés d'échec</td>
{{/rollLess() result 0}}
{{/rollWasFumble() result}}
{{#^rollWasFumble() result}}
{{#rollGreater() result 1}}
<td class="roll-success">{{result}} degrés de réussite</td>
{{/rollGreater() result 1}}
{{#rollBetween() result 0 1}}
<td class="roll-success">{{result}} degré de réussite</td>
{{/rollBetween() result 0 1}}
{{#rollLess() result 0}}
<td class="roll-fail">{{result}} degrés d'échec</td>
{{/rollLess() result 0}}
{{/^rollWasFumble() result}}
{{/^rollWasCrit() result}}
</tr>
</table>
</rolltemplate>
<rolltemplate class="sheet-rolltemplate-d10init">
<table class="">
<tr><th class="roll-title">{{name}} &mdash; {{roll_name}}</th></tr>
<tr><td class="roll-success"> 1d10+{{value}} = {{result}}
{{#rollWasCrit() result}}
<span class="inline fullcrit">+{{base}}</span>
{{/rollWasCrit() result}}
{{#rollWasFumble() result}}
{{result}}<span class="inline fullfail">-{{base}}</span>
{{/rollWasFumble() result}}
</td></tr>
</table>
</rolltemplate>
<rolltemplate class="sheet-rolltemplate-d10Shooting">
<div class="container">
<div><h1>{{name}}</h1></div>
<div><span class="subheader">{{subtags}}</span></div>
<div class="arrow-container"><div class="arrow-right"></div></div>
{{#attack}}
<div class="rowcolor"><span class="tcat">Attack: </span>{{attack}} successes</div>
{{#mode}}
<div class="rowcolor"><span class="tcat">Mode: </span>{{mode}} ({{usedammo}})</div>
{{/mode}}
{{/attack}}
{{#damage}}
<div>
<span class="tcat">Damage: </span>{{damage}}
</div>
{{#ammocurrent}}
<div>
<span class="tcat">Ammunition: </span> {{ammocurrent}}/{{magsize}} | {{ammototal}}
</div>
{{/ammocurrent}}
{{/damage}}
{{#damagedone}}
<div>
<span class="tcat">Damage: </span>{{damagedone}}
</div>
{{#ammocurrent}}
<div>
<span class="tcat">Ammunition: </span> {{ammocurrent}}/{{magsize}} | {{ammototal}}
</div>
{{/ammocurrent}}
{{/damagedone}}
{{#special}}
<div>
<span class="tcat">Special: </span>{{special}}
</div>
{{/special}}
</div>
</rolltemplate>
"""
css_footer = """input.sheet-tab{
-moz-appearance: none;
width:150px;
height: 20px;
top: 5px;
left: 6px;
margin: 5px;
cursor: pointer;
z-index: 1;
content: attr(title);
}
input.sheet-tab::before{
-moz-appearance: none;
content: attr(title);
border-radius:.5em;
border:2px solid black;
text-align: center;
display: inline-block;
background: black;
color:white;
width: 150px;
height: 20px;
font-size: 18px;
}
input.sheet-tab:checked::before{
-moz-appearance: none;
background:#CCCCCC;
color:black;
border-radius:.5em;
border:2px solid black;
}
input.sheet-small_tab{
-moz-appearance: none;
width:120px;
height: 20px;
cursor: pointer;
z-index: 1;
margin:5px;
}
input.sheet-small_tab::before{
-moz-appearance: none;
content: attr(title);
border-radius:.5em;
text-align: center;
display: inline-block;
color:white;
background:black;
border:2px solid black;
width: 120px;
height:20px;
font-size: 14px;
}
input.sheet-small_tab:checked::before{
-moz-appearance: none;
border:2px solid black;
background:#CCCCCC;
color:black;
border-radius:.5em;
}
input.sheet-skill_name{
-moz-appearance: none;
width:400px;
}
input.sheet-skill_hidden{
visibility: hidden;
}
div.sheet-tab-content{
border-top-color: #000;
margin: 2px 0 0 0;
}
select.sheet-skill_select{
width:55px;
margin-bottom:-1px;
}
select.sheet-dice_select{
width:85px;
margin-bottom:-1px;
}
.sheet-trait{
width: 30px;
}
.sheet-numberbox {
width: 50px;
}
.sheet-rolltemplate-d10init table,
.sheet-rolltemplate-d10skillcheck table {
border-radius: 6px;
width:100%;
padding:0px;
margin:0px;
padding: 2px;
border: 1px solid;
background-color: #ffffff;
border-width: 1px;
border-style: solid;
border-color: #000;
border-image-source: none;
}
.sheet-rolltemplate-d10init .sheet-roll-title,
.sheet-rolltemplate-d10init th,
.sheet-rolltemplate-d10skillcheck .sheet-roll-title,
.sheet-rolltemplate-d10skillcheck th {
color: rgb(42, 42, 42);
padding:0px;
margin:0px;
padding-left: 5px;
font-size: 1.2em;
text-align: left;
font-family: "Times New Roman", Times, serif;
font-variant: small-caps;
text-transform: capitalize;
border-width: 0px;
}
.sheet-rolltemplate-d10init .sheet-roll-attr,
.sheet-rolltemplate-d10skillcheck .sheet-roll-attr{
color: #555555;
font-size: 1em;
font-style: italic;
padding:0px;
margin:0px;
padding-left: 9px;
border-width: 0px;
margin-top: -10px;
}
.sheet-rolltemplate-d10init .sheet-roll-success,
.sheet-rolltemplate-d10skillcheck .sheet-roll-success ,
.sheet-rolltemplate-d10skillcheck .sheet-roll-fail {
padding:0px;
margin:0px;
border-width: 0px;
padding-left: 5px;
}
.sheet-rolltemplate-d10skillcheck .sheet-roll-crit {
padding:0px;
margin:0px;
border-width: 0px;
padding-left: 5px;
background-color:#b0d6ad;
}
.sheet-rolltemplate-d10skillcheck .sheet-roll-fumble {
padding-left: 5px;
border-width: 0px;
background-color:#d6adad;
}
.sheet-rolltemplate-d10init .sheet-inline,
.sheet-rolltemplate-d10init .inlinerollresult,
.sheet-rolltemplate-d10skillcheck .sheet-inline,
.sheet-rolltemplate-d10skillcheck .inlinerollresult {
background-color: transparent;
border: none;
font-weight: bold;
padding:0px;
font-family: "Times New Roman", Times, serif;
}
.sheet-rolltemplate-d10skillcheck .sheet-inline.sheet-fullcrit,
.sheet-rolltemplate-d10skillcheck .inlinerollresult.fullcrit {
color: #3FB315;
border: none;
}
.sheet-rolltemplate-d10skillcheck .sheet-inline.sheet-fullfail,
.sheet-rolltemplate-d10skillcheck .inlinerollresult.fullfail {
color: #B31515;
border: none;
}
.sheet-rolltemplate-d10skillcheck .inlinerollresult.importantroll {
color: #4A57ED;
border: none;
}
.sheet-rolltemplate-d10fight-blob{
border-radius: 6px;
border: 1px solid #898989;
z-index: 1;
}
.sheet-rolltemplate-d10fight table{
padding:0px;
margin:0px;
text-align: left;
width:100%;
border:none;
cellpadding:3px;
cellspacing:0px;
}
.sheet-rolltemplate-d10fight .sheet-sum{
padding:0px;
margin:0px;
border:none;
text-align: right;
padding-right:10px;
}
.sheet-rolltemplate-d10fight .sheet-success,
.sheet-rolltemplate-d10fight .sheet-line{
padding:0px;
margin:0px;
padding-left: 3px;
border:none;
}
.sheet-rolltemplate-d10fight .sheet-critical{
padding:0px;
margin:0px;
border:none;
padding-left: 3px;
border-radius: 4px;
background-color:#b0d6ad;
}
.sheet-rolltemplate-d10fight .sheet-hit{
padding:0px;
margin:0px;
padding-left: 3px;
border-radius: 4px;
background-color:#b0d6ad;
border:none;
}
.sheet-rolltemplate-d10fight .sheet-miss{
padding:0px;
margin:0px;
padding-left: 3px;
border:none;
border-radius: 4px;
background-color:#d6adad;
}
.sheet-rolltemplate-d10fight .sheet-name{
padding:0px;
padding-left: 3px;
margin:0px;
border:none;
border-radius: 4px;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
background-color: #999999;
}
.sheet-rolltemplate-d10fight .sheet-additional{
padding:0px;
margin:0px;
border:none;
padding-left:10px;
}
.sheet-rolltemplate-d10fight-grey{
color: #999999;
}
.sheet-rolltemplate-d10fight-green{
color: #009900;
}
.sheet-rolltemplate-d10fight a,
.sheet-rolltemplate-d10fight a[href^="!"],
.sheet-rolltemplate-d10fight a[href^="~"]{
text-align:right;
background-color: #999999; !important
}
.sheet-rolltemplate-d10Shooting .sheet-container {
background-color: #ffffff;
border: 1px solid;
padding: 2px;
width: 189px;
}
.sheet-rolltemplate-d10Shooting .sheet-container h1 {
color: rgb(126, 45, 64);
font-size: 1.2em;
font-variant: small-caps;
line-height: 20px;
}
.sheet-rolltemplate-d10Shooting div {
padding: 2px;
};
.sheet-rolltemplate-d10Shooting span {
color: rgb(126, 45, 64);
font-family: "Times New Roman", Times, serif;
font-size: 1.2em;
font-variant: small-caps;
line-height: 1.6em;
padding-left: 5px;
text-align: left;
}
.sheet-rolltemplate-d10Shooting .sheet-subheader {
color: #000;
font-size: 1em;
font-style: italic;
}
.sheet-rolltemplate-d10Shooting .sheet-arrow-right {
border-bottom: 2px solid transparent;
border-left: 180px solid rgb(126, 45, 64);
border-top: 2px solid transparent;
}
.sheet-rolltemplate-d10Shooting .sheet-tcat {
font-style: italic;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult {
background-color: #ffffff;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.fullcrit {
color: #3FB315;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.fullfail {
color: #B31515;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.importandivoll {
color: #4A57ED;
border: none;
}
select.sheet-weapon_type_select{
line-height: 0px;
margin-bottom:0px;
margin: 0px;
}
label {
display: inline;
margin: 0px;
padding: 0px;
}
div.sheet-row{
margin: 0px;
padding: 3px;
}
div.sheet-quickborder{
border: 1px solid #ccc;
border-color: grey;
margin:5px;
padding:5px;
}
div.repeating_ranged-weapon{
margin:5px;
}
"""

126
helpers/customs.py Normal file
View File

@ -0,0 +1,126 @@
import generator
__ALL__=["DISTANCE","MELEE"]
class DISTANCE(generator.Node):
"""DISTANCE Weapons"""
def __init__(self, name,nb):
super(DISTANCE, self).__init__("repeating_ranged-weapons",0)
def content(self):
ret=""" <!--ranged -->
<fieldset class="repeating_ranged-weapons">
<div class="quickborder">
<div class="sheet-row">
<input class="sheet-skill_name" type="number" name="attr_wid" title="Numero de ligne" />
<input class="sheet-skill_name" type="text" name="attr_ranged_weaponname" title="Nom de l'arme" />
<label>P</label>
<input type="number" name="attr_ranged_accuracy" title="Précision" />
<label>Mode</label>
<input type="number" name="attr_ranged_single" title="Coup par coup" />
<label>/</label>
<input type="number" name="attr_ranged_burst" title="Rafale" />
<label>/</label>
<input type="number" name="attr_ranged_auto" title="Automatique" />
</div>
<div class="sheet-row">
<label>Type</label>
<input type="text" name="attr_typename" title="Type d'arme" />
<select class="sheet-weapon_type_select" name="attr_ranged_type_select">
<option value="@{combat_skilllevel_armesdassaut}">Arme d'Assaut</option>
<option value="@{combat_skilllevel_armesdepoing}">Arme de Poing</option>
<option value="@{combat_skilllevel_munitionssolide}">Munitions Solides</option>
<option value="@{combat_skilllevel_projectilesbalistiques}">Arme Balistique</option>
<option value="@{combat_skilllevel_projectilesautopropulss}">Projectile Autopropulsé</option>
<option value="@{combat_skilllevel_armementlaser}">Armement Laser</option>
<option value="@{combat_skilllevel_guidagedemissiles}">Guidage de Missiles</option>
<option value="@{combat_skilllevel_balistique}">Balistique Superlative</option>
<option value="0">Aucune spécialité</option>
</select>
<button type='roll' class="sheet-skillbutton" title ="Dégats" value="&{template:d10Shooting} {{name=@{ranged_weaponname}}} {{subtags=@{typename}}} {{damagedone=[[(?{successes}-1)*@{ranged_dmgPlus}+@{ranged_dmgBase}]]}} {{magsize=@{ranged_magT}}} {{ammocurrent=@{ranged_magA}}} {{ammototal=@{ranged_ammoT}}}">Dégats</button>
<button type='roll' class="sheet-skillbutton" title ="Rechargement" value="/em reloads the @{ranged_weaponname} loosing @{ranged_magA} ammo in the process. &#13;!setattr --name @{character_name} --repeating_ranged-weapons_$@{wid}_ranged_magA|[[{@{ranged_magT},@{ranged_ammoT}}kl1]] --repeating_ranged-weapons_$@{wid}_ranged_ammoT|[[{0,@{ranged_ammoT}-@{ranged_magT}}kh1]]">Rechargement</button>
</div>
<div class="sheet-row">
<label>Chargeur</label>
<input type="number" name="attr_ranged_magA" title="Chargeur Actuel" />
<label>/</label>
<input type="number" name="attr_ranged_magT" title="Chargeur Total" />
<label>|</label>
<input type="number" name="attr_ranged_ammoT" title="Munitions Totales" />
<label>Dégats</label>
<input type="number" name="attr_ranged_dmgBase" title="Dégats base" />
<label>/</label>
<input type="number" name="attr_ranged_dmgPlus" title="Dégats additionels" />
<label>Spécial</label>
<input type="text" name="attr_ranged_special" title="Spécial" />
<button type='roll' class="sheet-skillbutton" title ="Tir simple" value="&{template:d10Shooting}{{name=@{ranged_weaponname}}}{{subtags=@{typename}}} {{attack=[[?{Dices}d10<[[@{ranged_type_select}+?{Seuil|4}+@{ranged_accuracy}]]cs1cf11]]}} {{mode=Single Shot}} {{damage=@{ranged_dmgBase}/+@{ranged_dmgPlus}}} {{usedammo=@{ranged_single}}} {{magsize=@{ranged_magT}}} {{ammocurrent=[[@{ranged_magA}-@{ranged_single}]]}} {{ammototal=@{ranged_ammoT}}} {{special=@{ranged_special}}} !modattr --name @{character_name} --repeating_ranged-weapons_$@{wid}_ranged_magA|-@{ranged_single}!!!">S</button>
<button type='roll' class="sheet-skillbutton" title ="Rafale" value="&{template:d10Shooting}{{name=@{ranged_weaponname}}}{{subtags=@{typename}}} {{attack=[[[[?{Dices}+1]]d10<[[@{ranged_type_select}+?{Seuil|4}+@{ranged_accuracy}]]cs1cf11]]}} {{mode=Burst}} {{damage=@{ranged_dmgBase}/@{ranged_dmgPlus}}} {{usedammo=@{ranged_burst}}} {{magsize=@{ranged_magT}}} {{ammocurrent=[[@{ranged_magA}-@{ranged_burst}]]}} {{ammototal=@{ranged_ammoT}}} {{special=@{ranged_special}}} !modattr --name @{character_name} --repeating_ranged-weapons_$@{wid}_ranged_magA|-@{ranged_burst}!!!">B</button>
<button type='roll' class="sheet-skillbutton" title ="Automatique" value="&{template:d10Shooting}{{name=@{ranged_weaponname}}}{{subtags=@{typename}}} {{attack=[[?{Dices}d10<[[@{ranged_type_select}+?{Seuil|4}+@{ranged_accuracy}]]cs1cf11]]}} {{mode=Auto}} {{damage=@{ranged_dmgBase}/@{ranged_dmgPlus}}} {{usedammo=@{ranged_auto}}} {{magsize=@{ranged_magT}}} {{ammocurrent=[[@{ranged_magA}-@{ranged_auto}]]}} {{ammototal=@{ranged_ammoT}}} {{special=@{ranged_special}}} !modattr --name @{character_name} --repeating_ranged-weapons_$@{wid}_ranged_magA|-@{ranged_auto}!!!">A</button>
</div> </div>
</fieldset>
"""
return ret
class MELEE(generator.Node):
"""MELEE Weapons"""
def __init__(self, name,nb):
super(MELEE, self).__init__(name,nb)
def content(self):
ret=""" <!-- Melée -->
<fieldset class="repeating_melee-weapons">
<div class="quickborder">
<div class="sheet-row">
<input class="sheet-skill_name" type="number" name="attr_wid" title="Numero de ligne" />
<input class="sheet-skill_name" type="text" name="attr_melee_weaponname" title="Nom de l'arme" />
<label>P</label>
<input type="number" name="attr_melee_accuracy" title="Précision" />
</div>
<div class="sheet-row">
<label>Type</label>
<input type="text" name="attr_typename" title="Type d'arme" />
<select class="sheet-weapon_type_select" name="attr_melee_type_select">
<option value="@{combat_skilllevel_armescontandantes}">Arme Contandante</option>
<option value="@{combat_skilllevel_armestranchantes}">Arme Tranchante</option>
<option value="0">Aucune spécialité</option>
</select>
</div>
<div class="sheet-row">
<label>Dégats</label>
<input type="number" name="attr_melee_dmgBase" title="Dégats base" />
<label>/</label>
<input type="number" name="attr_melee_dmgPlus" title="Dégats additionels" />
<label>Spécial</label>
<input type="text" name="attr_melee_special" title="Spécial" />
<button type='roll' class="sheet-skillbutton" title ="Attaque" value="&{template:d10Shooting}{{name=@{melee_weaponname}}}{{subtags=@{typename}}} {{attack=[[?{Dices}d10<[[@{melee_type_select}+?{Seuil|4}+@{melee_accuracy}]]cs1cf11]]}} {{damage=@{melee_dmgBase}/+@{melee_dmgPlus}}} {{special=@{melee_special}}}">Attaque</button>
<button type='roll' class="sheet-skillbutton" title ="Dégats" value="&{template:d10Shooting}{{name=@{melee_weaponname}}}{{subtags=@{typename}}} {{damagedone=[[(?{successes}-1)*@{melee_dmgPlus}+@{melee_dmgBase}]]}}">Dégats</button>
</div> </div>
</fieldset>
"""
return ret
class CONSOMMABLE(generator.Node):
"""CONSUMMABLES"""
def __init__(self, name,nb):
super(CONSOMMABLE, self).__init__(name,nb)
def content(self):
return """ <fieldset class="repeating_consumables">
<div class="quickborder">
<div class="sheet-row">
<input class="sheet-skill_name" type="number" name="attr_wid" title="Numero de ligne" />
<input class="sheet-skill_name" type="text" style="width:250px" name="attr_consumable_name" title="Nom du consommable" />
<input class="sheet-skill_name" type="text" style="width:200px" name="attr_consumable_type" title="Type de consommable" />
<label>Nb</label>
<input type="number" name="attr_consumable_nb" title="Quantité" />
<button type='roll' class="sheet-skillbutton" title ="Utilisation" value="&{template:d10Shooting}{{name=@{consumable_name}}}{{subtags=@{consumable_type}}} {{special=@{consumable_effect}}} !modattr --name @{character_name} --repeating_consumables_$@{wid}_consumable_nb|-1!!!">Utiliser</button>
</div>
<div class="sheet-row">
<input type="text" style="" name="attr_consumable_effect" style="width:100%" title="Description (short)" />
</div> </div>
</fieldset>
"""

135
helpers/cyberpnk.txt Normal file
View File

@ -0,0 +1,135 @@
@ Physique
+ Combat
= Armes à feu
- &#8677; Armes d'assaut
- &#8677; Armes de poing
= Armes Lourdes
- &#8677; Munitions solide
- &#8677; Projectiles autopropulsés
- &#8677; Armement laser
= Artillerie
- &#8677; Projectiles balistiques
- &#8677; Guidage de missiles
- &#8677; Systemes de défenses
- &#8677; Balistique superlative
= Combat à Mains Nues
- &#8677; Neo Kwon Do
- &#8677; Zero-G
= Combat Armé
- &#8677; Armes Contondantes
- &#8677; Armes Tranchantes
= Maniement des Explosifs
+ Physiques
= Athlétisme
- &#8677; Aerien
- &#8677; Terrestre
- &#8677; Maritime
- &#8677; Zero G
= Survie
- &#8677; Environnement Sauvage
- &#8677; Environnement Urbain
- &#8677; Environnement Spacial
+ Implants
= Utilisation de Cyberware
- &#8677; Utilisation de Neuro Accelerateurs
- &#8677; Utilisation d'Interfaces de tir
- &#8677; Overdrive Physique
+ Pilotage
= Pilotage atmosphérique
- &#8677; Pilotage de Chasseurs
- &#8677; Pilotage de Navettes
= Vehicules Terrestres
- &#8677; Vehicules Légers
- &#8677; Vehicules Lourds
- &#8677; Véhicules de Course
= Vaisseaux Spatiaux
- &#8677; Bâtiments légers
- &#8677; Bâtiments lourds
- &#8677; Bâtiments super lourds
@ Intelectuelles
+ Techniques
= Biotech
- &#8677; Chirurgie d’implants
= Électronique
- &#8677; Interconnection des systèmes
- &#8677; Verrous magnétiques
= Informatique
- &#8677; Hardware
- &#8677; Software
- &#8677; Systèmes embarqués
= Mécanique
- &#8677; Réacteurs à Fusion
- &#8677; Réacteurs à Fission
- &#8677; Compensateurs d'Inertie
- &#8677; Technologie Lightfold
- &#8677; Systèmes de Survie
- &#8677; Systèmes de Propulsion
= Prospection stellaire
- &#8677; Corps stellaires
- &#8677; Excavation planetaire
+ Connaissances
= Bioware
- &#8677; Implants Céphaliens
- &#8677; Implants Corporels
= Médecine
- &#8677; Soins Intensifs
- &#8677; Cybernetisation
= Sciences
- &#8677; Astromathématiques
- &#8677; Biologie
- &#8677; Xenobiologie
- &#8677; Mathématiques
- &#8677; Physique/Chimie
- &#8677; Lightfold
- &#8677; Sociologie
+ Culture Générale
= Instruction Civique
- &#8677; Administratif/Politique/Droit
- &#8677; Finances
- &#8677; Psychologie
= Théorie Militaire
- &#8677; Tactique
- &#8677; Stratégie
@ Sociales
+ Relations humaines
= Étiquette
- &#8677; Alpha Centauri
- &#8677; Eridani
- &#8677; Banard
- &#8677; Tau
- &#8677; Sirius
- &#8677; C.I.C.
- &#8677; Sol
- &#8677; Pègre
= Interrogation
- &#8677; Intimidation
= Commandement
= Négociation
= Barratin
+ Clandestines
= Discrétion
= Crochetage
= Informations
= Larcin
= Marchés noirs
- &#8677; Acquisition d’Objets
- &#8677; Acquisition d’Informations
+ Contacts
. Contacts
@ Arsenal
+ Distance
# DISTANCE
+ Mêlée
# MELEE
+ Consommable
# CONSOMMABLE

250
helpers/generator.py Normal file
View File

@ -0,0 +1,250 @@
# -*- coding: utf-8 -*-
# content skills sections and others from a file, on the long run, it should be able to content the whole sheet
import argparse, sys, os
import string
# from unidecode import unidecode
# import unicode
def remove_non_ascii(text):
return "".join([c for c in text if c in string.ascii_letters]).strip(" ")
# return unidecode(text)
class Node(object):
"""Generic Node."""
def __init__(self, name,nb):
self.name = name#name.strip(" ")
self.number=nb
self.children=[]
self.checked=""
self.parent=None
self.pname=u""+remove_non_ascii(self.name.replace(" ","")).lower()
if nb==1:
self.checked='checked="checked"'
def content(self):
return ""
def header(self):
return ""
def css(self):
return ""
def addchild(self,child):
self.children+=[child]
child.parent=self
class Root(Node):
"""docstring for Root."""
def __init__(self):
super(Root,self).__init__("",0)
def generate(self):
"Return the whole tree, printable"
return self.content()
def content(self):
ret=""
for child in self.children:
ret+=child.header() # Ligne de chaque tab direct, puis tout
for child in self.children:
ret+=child.content()
ret+="</div>\n"
return ret
def css(self):
"Return the whole css, printable"
ret="div.sheet-tab-content { display: none; }"
for child in self.children:
ret+="\ninput.sheet-tab{node.number}:checked ~ div.sheet-tab{node.number},".format(node=child)
ret=ret[:-1]
ret+="\n{\n display: block;\n}\n"
for child in self.children:
ret+=child.css()
return ret
class Tab(Node):
"""Tab node, contains"""
def __init__(self, name,nb):
super(Tab, self).__init__(name,nb)
def header(self): # Comes first
return '<input type="radio" name="attr_tab" class="sheet-tab sheet-tab{self.number}" value="{self.number}" title="{self.name}" {self.checked}/><span></span>\n'.format(self=self)
def content(self):
ret='<!-- {self.pname} -->\n<div class="sheet-tab-content sheet-tab{self.number}">\n'.format(self=self) # And add all content
for child in self.children:
ret+=child.header()
for child in self.children:
ret+=child.content()
return ret
def css(self):
ret=" "
for child in self.children:
ret+="\ninput.sheet-secondary_{node.pname}_tab{child.number}:checked ~ div.sheet-secondary_{node.pname}_tab{child.number},".format(child=child,node=self)
ret=ret[:-1]
ret+="\n{\n display: block;\n}"
return ret
class SubTab(Node):
def __init__(self,name,nb):
super(SubTab,self).__init__(name,nb)
def header(self):
return """ <input type="radio" name="secondary_{self.parent.pname}_tab" class="small_tab secondary_{self.parent.pname}_tab{self.number}" value="{self.number}" {self.checked} title="{self.name}" />\n""".format(self=self)
def content(self):
ret= ' <div class="sheet-tab-content sheet-secondary_{self.parent.pname}_tab{self.number}">\n'.format(self=self)
ret+=" <!-- {self.name} -->\n <h3>{self.name}</h3>\n".format(self=self)
for child in self.children:
ret+=child.content()
ret+=" </div>\n"
return ret
def css(self):
return ""
class Skill(Node):
"""Print a skill."""
def __init__(self, name,nb):
super(Skill, self).__init__(name,nb)
def content(self): # {self.parent.pname} is not needed, else _skilllevel_ cause a confict, legacy keeping I guess ?
ret=""" <!--{self.name} -->
<input class="sheet-skill_name" style="margin-right: 4px;" type="text" name="attr_{self.parent.pname}_skill_{self.pname}" disabled="true" value="{self.name}" />
<input type="number" min="0" value="0" name="attr_{self.parent.pname}_skillcost_{self.pname}" title="Coût de la compétence" />
<input class="sheet-skill_name" value="0" style="margin-right: 4px;" type="number" min="0" max="10" name="attr_{self.parent.pname}_skilllevel_{self.pname}" title="Niveau dans la compétence" />
<select class="sheet-skill_select" style="margin-right:4px" name="attr_skill_{self.parent.pname}_attribute_select_{self.pname}">
<option value="@{{base-Force}} + @{{exal-Force}}">For</option>
<option value="@{{base-Agilite}} + @{{exal-Agilite}}">Agi</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Charisme}} + @{{exal-Charisme}}">Cha</option>
<option value="@{{base-Intelligence}} + @{{exal-Intelligence}}">Int</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Volonte}} + @{{exal-Volonte}}">Vol</option>
<option value="@{{base-Psyche}} + @{{exal-Psyche}}">Psy</option>
<option value="@{{base-Chance}} + @{{exal-Chance}}">Chn</option>
</select>
<button type='roll' class="sheet-skillbutton" value="&{{template:d10skillcheck}} {{{{name=@{{character_name}}}}}} {{{{roll_name=@{{{self.parent.pname}_skill_{self.pname}}}}}}} {{{{dice_name=@{{dice}}}}}} {{{{result=[[@{{{self.parent.pname}_skilllevel_{self.pname}}}+(@{{skill_{self.parent.pname}_attribute_select_{self.pname}}})-d@{{dice}}cs1cf@{{dice}}]]}}}} {{{{threshold=[[@{{{self.parent.pname}_skilllevel_{self.pname}}}+(@{{skill_{self.parent.pname}_attribute_select_{self.pname}}})]]}}}}"></button>
<br/>\n""".format(self=self)
return ret
class SubSkill(Node):
"""Print a subskill."""
def __init__(self, name,nb,superskill):
super(SubSkill, self).__init__(name,nb)
self.superskill=superskill
print(name,superskill.pname)
def content(self): # {self.parent.pname} is not needed, else _skilllevel_ cause a confict, legacy keeping I guess ?
ret=""" <!--{self.name} -->
<input class="sheet-skill_name" style="margin-right: 4px;" type="text" name="attr_{self.parent.pname}_skill_{self.pname}" disabled="true" value="{self.name}" />
<input type="number" min="0" value="0" name="attr_{self.parent.pname}_skillcost_{self.pname}" title="Coût de la compétence" />
<input class="sheet-skill_name" value="0" style="margin-right: 4px;" type="number" min="0" max="10" name="attr_{self.parent.pname}_skilllevel_{self.pname}" title="Niveau dans la compétence" />
<select class="sheet-skill_select" style="margin-right:4px" name="attr_skill_{self.parent.pname}_attribute_select_{self.pname}">
<option value="@{{base-Force}} + @{{exal-Force}}">For</option>
<option value="@{{base-Agilite}} + @{{exal-Agilite}}">Agi</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Charisme}} + @{{exal-Charisme}}">Cha</option>
<option value="@{{base-Intelligence}} + @{{exal-Intelligence}}">Int</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Volonte}} + @{{exal-Volonte}}">Vol</option>
<option value="@{{base-Psyche}} + @{{exal-Psyche}}">Psy</option>
<option value="@{{base-Chance}} + @{{exal-Chance}}">Chn</option>
</select>
<button type='roll' class="sheet-skillbutton" value="&{{template:d10skillcheck}} {{{{name=@{{character_name}}}}}} {{{{roll_name=@{{{self.parent.pname}_skill_{self.pname}}}}}}} {{{{dice_name=@{{dice}}}}}} {{{{result=[[@{{{self.parent.pname}_skilllevel_{self.pname}}}+(@{{skill_{self.parent.pname}_attribute_select_{self.pname}}}+@{{{self.parent.pname}_skilllevel_{self.superskill.pname}}})-d@{{dice}}cs1cf@{{dice}}]]}}}} {{{{threshold=[[@{{{self.parent.pname}_skilllevel_{self.pname}}}+@{{{self.parent.pname}_skilllevel_{self.superskill.pname}}}+(@{{skill_{self.parent.pname}_attribute_select_{self.pname}}})]]}}}}"></button>
<br/>\n""".format(self=self)
return ret
class Repeating(Node):
"""Repeating section"""
def __init__(self, name,nb):
super(Repeating, self).__init__(name,nb)
def content(self):
ret=""" <!-- {node.pname} -->
<fieldset class="repeating_{node.pname}-skills">
<input class="sheet-skill_name" type="text" name="attr_{node.pname}_skillname" />
<input type="number" name="attr_{node.pname}_skillcost" title="Coût de la compétence" />
<input type="number" min="-10" max="10" name="attr_{node.pname}_skilllevel" title="Niveau dans la compétence" />
<select class="sheet-skill_select" name="attr_{node.pname}_attribute_select">
<option value="@{{base-Force}} + @{{exal-Force}}">For</option>
<option value="@{{base-Agilite}} + @{{exal-Agilite}}">Agi</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Charisme}} + @{{exal-Charisme}}">Cha</option>
<option value="@{{base-Intelligence}} + @{{exal-Intelligence}}">Int</option>
<option value="@{{base-Perception}} + @{{exal-Perception}}">Per</option>
<option value="@{{base-Volonte}} + @{{exal-Volonte}}">Vol</option>
<option value="@{{base-Psyche}} + @{{exal-Psyche}}">Psy</option>
<option value="@{{base-Chance}} + @{{exal-Chance}}">Chn</option>
</select>
<button type='roll' class="sheet-skillbutton" value="&{{template:d10skillcheck}}\
{{{{name=@{{character_name}}}}}}\
{{{{roll_name=@{{{node.pname}_skillname}}}}}}\
{{{{dice_name=@{{dice}}}}}}\
{{{{result=[[@{{{node.pname}_skilllevel}}+(@{{{node.pname}_attribute_select}})-d@{{dice}}cs1cf@{{dice}}]]}}}}\
{{{{threshold=[[@{{{node.pname}_skilllevel}}+(@{{{node.pname}_attribute_select}})]]}}}}">\
</button>
</fieldset>
<br/>\n""".format(node=self)
return ret
if __name__ == '__main__':
# filen=sys.argv[1]
# filen="light.txt"
import customs as custom_skills
filen="cyberpnk.txt"
output="systemd10cyberpunk.html"
outcss="systemd10cyberpunk.css"
def parse(filen):
root=Root()
active_tab,active_subtab=None,None
tab_nb,subtab_nb,skill_nb,repeating_nb=1,1,1,1
mainskill=None
try:
with open(filen,encoding="utf-8") as f:
for line in f.readlines():
if line[0]=="@": # Tab
active_tab=Tab(line[1:-1],tab_nb)
root.addchild(active_tab)
tab_nb+=1
subtab_nb=1
elif line[0]=="+":
active_subtab=SubTab(line[1:-1],subtab_nb)
active_tab.addchild(active_subtab)
subtab_nb+=1
skill_nb=1
elif line[0]=="=":
tech_content=Skill(line[1:-1],skill_nb)
active_subtab.addchild(tech_content)
mainskill=tech_content
skill_nb+=1
elif line[0]=="-":
tech_content=SubSkill(line[1:-1],skill_nb,mainskill)
active_subtab.addchild(tech_content)
skill_nb+=1
elif line[0]==".":
tech_content=Repeating(line[1:-1],repeating_nb)
active_subtab.addchild(tech_content)
repeating_nb+=1
elif line[0]=="#":
skill=custom_skills.__getattribute__(line[2:-1])("","")
active_subtab.addchild(skill)
repeating_nb+=1 # ???
except FileNotFoundError:
print(filen,"was not found")
return root
root=parse(filen)
import base
with open(output,"w",encoding="utf-8") as f:
f.write(base.head)
f.write(base.script)
f.write(base.header)
f.write(root.content())
f.write(base.footer)
with open(outcss,"w",encoding="utf-8") as f:
f.write(root.css())
f.write(base.css_footer)

5
helpers/light.txt Normal file
View File

@ -0,0 +1,5 @@
@ Physique
+ Combat
- Armes à feu
+ Soc
- Charisme

423
helpers/skill_generator.py Normal file
View File

@ -0,0 +1,423 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Not actually part of the project; just easier to maintain everything here
import importlib
import re
import sys,os
import traceback
try:
# path=os.path.join(os.path.dirname(__file__),"..","minitest")
# minitest=importlib.import_module("...minitest.minitest","skill_generator")
from minitest import minitest
term = minitest.Terminal()
from test import testReroll,testInit,testWrapper,testParser
except ImportError as e:
print(e)
print("Minitest isn't imported, the system cannot execute test units")
try:
args = sys.argv[1:]
command = sys.argv[1]
except:
print("No command specified, just outputting the help")
command = "help"
EOL = "\n"
tab = " "
# Custom parsing
ENCAISSEMENT_PARSE = """d_vars.encaissement=to_number(tab[i+1]);
d_vars.encaissement_dices="d20";
if (tab[i+2]=="4") d_vars.encaissement_dices="d10";
i+=3;
break;"""
FLAT_DICES_PARSE = """d_vars.flat_dices[d_vars.nb_flat_dices]=to_p_number(tab[i+1]);
d_vars.nb_flat_dices++;
i+=2;
break;"""
TECHNIQUE_PARSE = """d_vars.technique_m=to_p_number(tab[i+2]);
i+=3;
break;"""
## Custom adders:
lambda_flat_dices = lambda a: "@flat_dices[@flat_dices]=type({tab+1});\n@nb_flat_dices++;"
## Custom rerolls:
categories = ['varname', 'Pretty name', 'nb_args', 'type', 'code', 'id', 'default', 'action', 'parser']
hashedCategories = {}
for c in range(len(categories)):
hashedCategories[categories[c]] = c
def findCat(element, category):
return element[hashedCategories[category]]
list = []
# list.append(['varname','Pretty name','nb_args','type','code','id','default','action','parser'])
list.append(['perfection', 'Perfection', 1, 'pint', 'P', 0, 0, "", None])
list.append(['defense_i_0', 'Defence impénétrable simple', 2, 'pint', 'I', 1, 0, "", None])
list.append(['defense_i_1', 'Defence impénétrable expert', 2, 'pint', 'I', 2, 0, "", None])
list.append(['defense_i_2', 'Defence impénétrable meta', 2, 'pint', 'I', 4, 0, "", None])
list.append(['rempart_p', 'Rempart parfait', 1, 'pint', 'R', 0, 0, "", None])
list.append(['technique_m', 'Perfection', 1, 'pint', 'M', 0, 0, "", TECHNIQUE_PARSE]) # +=3
list.append(['coup_d', 'Coup_déchirant', 1, 'pint', 'D', 0, 0, "", None])
list.append(['fauchage', 'Fauchage', 1, 'pint', 'F', 0, 0, "", None])
list.append(['exploiter_p_0', 'Exploiter_les_points_faibles simple', 2, 'pint', 'E', 1, 0, "", None])
list.append(['exploiter_p_1', 'Exploiter_les_points_faibles expert', 2, 'pint', 'E', 2, 0, "", None])
list.append(['exploiter_p_2', 'Exploiter_les_points_faibles meta', 2, 'pint', 'E', 4, 0, "", None])
list.append(['tir_p_0', 'Tir_précis expert', 2, 'pint', 'T', 2, 0, "", None])
list.append(['tir_p_1', 'Tir_précis meta', 2, 'pint', 'T', 4, 0, "", None])
list.append(['tir_i', 'Tir_implacable', 1, 'pint', 'i', 0, 0, "", None])
list.append(['charge', 'Charge', 1, 'pint', 'C', 0, 0, "", None])
list.append(['charge_i', 'Charge_indomptable', 1, 'pint', 'N', 0, 0, "", None])
list.append(['nb_2add', 'Nombre à ajouter', 1, 'int', '+', 0, 0, "+", None])
list.append(['nb_2sub', 'Nombre a soustraire', 1, 'int', '-', 0, 0, "+", None])
list.append(['relances', 'Relances', 1, 'pint', 'r', 0, 0, "", None])
list.append(['seuil', 'Seuil', 1, 'pint', 's', 0, 0, "", None])
list.append(['action', 'Type d\'Action', 1, 'str', 'a', 0, '""', "", None])
list.append(['flat_dices', 'Des fixes', 1, 'pint', 'd', 0, "[]", "+", FLAT_DICES_PARSE])
list.append(['on_hit_c', 'Dégats a l\'impact critique', 1, 'int', 'H', 0, 0, "+", None])
list.append(['attribute', 'Caractéristique', 1, 'int', 'A', 0, 0, "+", None])
list.append(['encaissement', 'Encaissement', 1, 'pint', 'S', 0, 0, "",
ENCAISSEMENT_PARSE]) # It's actually 2 args but no switch
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', 'n', 0, '""', "", None])
list.append(['crit_level', 'Niveau de critique', 1, 'pint', 'c', 0, 2, "", None])
list.append(['transcendence', 'Transcendence', 1, 'pint', 't', 0, 3, "", None])
list.append(['pctreceived', 'Pourcentage dégats recus', 1, 'int', 'v', 0, 0, "", None])
list.append(['pctinflicted', 'Pourcentage dégats infligés', 1, 'int', 'f', 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])
list.append(['encaissement_dices', 'Perfection', 1, 'pint', '', 0, '""', "", None])
list.append(['results', 'Resultats', 1, 'pint', '', 0, "[]", "", None])
list.append(['cleave', 'Fauchage', 1, 'pint', '', 0, "[]", "", None])
list.append(['encaissement_result', 'Resultat d\'encaissement', 1, 'pint', '', 0, 0, "", None])
list.append(['technique_result', 'Dégats technique martiale', 1, 'int', '', 0, 0, "", None])
list.append(['coup_d_results', 'Coup déchirant results', 1, 'pint', '', 0, "[]", "", None])
class megaListWrapper():
def __init__(self, table=list):
self.table = table
self.len = len(table)
self.indexes = {}
for i in range(len(table)):
self.indexes[findCat(table[i], "varname")] = i
# Theese are array because you can't acess them directly
self.singles = []
self.code = []
self.doubles = {}
for i in table:
if findCat(i, 'nb_args') == 1:
self.singles.append(i)
elif findCat(i, 'nb_args') == 2:
n = findCat(i, 'code')
if n not in self.doubles:
self.doubles[n] = []
self.doubles[n].append(i)
if findCat(i, 'code') != '':
self.code.append(i)
def __getitem__(self, argument): # Actually return the full line as a list wrapper
return listWrapper(self.table[self.indexes[argument]])
def __iter__(self):
for index, key in self.indexes.items():
yield self[index]
def itersingles(self):
"Only iterate over the simple argument ones"
for index in self.singles:
yield self[findCat(index, 'varname')]
def iterdoubles(self):
"Only iterate over the double arguments ones return a table with all"
for table in self.doubles.values():
yield [self[findCat(l, 'varname')] for l in table]
def iterdefined(self):
"Only iterate over the ones with defined code"
pass
def __contains__(self, val):
return val in self.indexes
def __len__(self):
return self.len
def pprint(self):
for e in self:
print(e[0], ":", e)
class listWrapper():
def __init__(self, list, index=hashedCategories):
self.list = list
self.indexes = index
def pprint(self):
print(self.list)
def asList(self):
return self.list
def __len__(self):
return len(self.list)
def __repr__(self):
return str(self.list)
def __getitem__(self, nb):
return self.list[nb]
def __getattr__(self, index):
return self.list[self.indexes[index]]
def __iter__(self):
for e in self.list:
yield e
## Commands
def initialise(args):
"Initialise the variables for the switch"
text = "var d_vars={"
for line in list:
text += '"{}":{},'.format(line[0], line[6])
text = text[:-1] + '};'
return text
def pprint(args):
"Print the whole list of values"
for i in list:
print(i)
def pErrors(name, errors):
"Print success or error of given test"
if errors:
print("{:<15}: {} errors occured".format(name, errors))
else:
print("{:<15}: All test successful".format(name))
return errors
def reroll(args):
"Generate the reroll inline message"
reroll = "var msg_relance=\"<a class='sheet-rolltemplate-d10fight' href='!crit 0"
def addZero(name):
return '"+d_vars.{}+"'.format(name)
def addOne(code, name):
return ' {} {}'.format(code, addZero(name))
def addTwo(code, id, name):
return ' {} {} {}'.format(code, id, addZero(name))
def addSimple(wline):
if wline.code != "" and wline.code not in ("r", "+", 'M', 'D', "d", "S"):
if wline.nb_args == 1:
return addOne(wline.code, wline.varname)
elif wline.nb_args == 2:
return addTwo(wline.code, wline.id, wline.varname)
else:
# print("{} must be handled differently".format(wline.varname))
return ""
# Actual adding of all the lines
for l in wrapper:
reroll += addSimple(l)
# Some lines needs to be added afterwards
reroll += ' + "+(d_vars.{}+d_vars.{}+d_vars.{})'.format(wrapper["nb_2add"].varname,
wrapper["technique_result"].varname,
wrapper["encaissement_result"].varname)
# Last part of the command
reroll += '+" r ?{Relances ?}";\n'
reroll += 'for (var i=0,len=d_vars.results.length;i<len;i++) msg_relance+=" d "+d_vars.results[i];\n'
reroll += 'msg_relance+="\'>Relancer ce jet</a>";'
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:
if len(listFree) == 1:
return 'The code "{}" is available.'.format(listFree)
else:
return 'The following 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"
res = tab + "if (len_args>0){" + EOL
res += tab * 2 + "d_vars.nb_dices=to_p_number(tab[0]);" + EOL
res += tab + "}" + EOL
res += tab + "for (i = 1; i < len_args;) {" + EOL
res += tab * 2 + "switch(tab[i]) {" + EOL
def typewise(type):
if type == "pint":
return "to_p_number({});"
elif type == 'int':
return "to_number({});"
return "{};"
doubles = {}
for elt in wrapper.itersingles():
if elt.parser:
res += tab * 3 + 'case "{}":'.format(elt.code) + EOL
for l in elt.parser.splitlines():
res += tab * 4 + l + EOL
elif elt.code != "":
res += tab * 3 + 'case "{}":'.format(elt.code) + EOL
res += tab * 4 + 'd_vars.{}{}={}'.format(elt.varname, elt.action,
typewise(elt.type).format("tab[i+1]")) + EOL
res += tab * 4 + 'i+=2;' + EOL
res += tab * 4 + 'break;' + EOL
for grp in wrapper.iterdoubles():
res += tab * 3 + 'case "{}":'.format(grp[0].code) + EOL
res += tab * 4 + 'switch (tab[i+1]) {' + EOL
for elt in grp:
if elt.parser:
for l in elt.parser.splitlines():
res += tab * 5 + l + EOL
elif elt.code != "":
res += tab * 5 + 'case "{}":'.format(elt.id) + EOL
res += tab * 6 + 'd_vars.{}{}={}'.format(elt.varname, elt.action,
typewise(elt.type).format("tab[i+2]")) + EOL
res += tab * 6 + 'break;' + EOL
if not elt.parser:
res += tab * 4 + "}" + EOL
res += tab * 4 + 'i+=3;' + EOL
res += tab * 4 + 'break;' + EOL
res += tab * 3 + "default:" + EOL
res += tab * 4 + 'logit("Argument "+tab[i]+" unknown.");' + EOL
res += tab * 4 + "i++;" + EOL
res += tab * 4 + "break;" + EOL
res += tab * 2 + "}" + EOL
res += tab * 1 + "}" + EOL
return res
def export(args):
if len(args) > 1:
filen = args[1]
try:
f = open(filen)
except:
filen = "export.log"
f = open(filen, "w+")
def title(t):
return "{} {} {}".format("#" * 10, t, "#" * 10) + EOL
f.write(title("Relances"))
f.write(reroll([]) + EOL)
f.write(title("Reroll"))
f.write(initialise([]) + EOL)
f.write(title("Parse"))
f.write(parser([]) + EOL)
f.close()
return "All data written in '{}'".format(filen)
def test_all(args):
"Execute all tests"
subclass = minitest.testGroup("Main Classes", term, verbose=True)
all_s, t = ["reroll", "init", "wrapper", "parser"], 0
if len(args) > 1:
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"
print("List of availables commands")
for key in commands.keys():
print(" {}: {}".format(key, commands[key].__doc__))
commands = {"init": initialise, "print": pprint, "reroll": reroll,
"test": test_all, "code": find_code, "parser": parser, "export": export, "help": help}
if __name__ == '__main__':
wrapper = megaListWrapper()
try:
ret = commands[command](args)
if ret:
print(ret)
except KeyError:
print("Command {} doesn't exist".format(command))
commands['help'](args)
except Exception:
print("Couldn't execute command " + command)
print(" > {} ({})".format(sys.exc_info()[1], sys.exc_info()[0]))
traceback.print_tb(sys.exc_info()[2])

View File

@ -0,0 +1,373 @@
div.sheet-tab-content { display: none; }
input.sheet-tab1:checked ~ div.sheet-tab1,
input.sheet-tab2:checked ~ div.sheet-tab2,
input.sheet-tab3:checked ~ div.sheet-tab3,
input.sheet-tab4:checked ~ div.sheet-tab4
{
display: block;
}
input.sheet-secondary_physique_tab1:checked ~ div.sheet-secondary_physique_tab1,
input.sheet-secondary_physique_tab2:checked ~ div.sheet-secondary_physique_tab2,
input.sheet-secondary_physique_tab3:checked ~ div.sheet-secondary_physique_tab3,
input.sheet-secondary_physique_tab4:checked ~ div.sheet-secondary_physique_tab4
{
display: block;
}
input.sheet-secondary_intelectuelles_tab1:checked ~ div.sheet-secondary_intelectuelles_tab1,
input.sheet-secondary_intelectuelles_tab2:checked ~ div.sheet-secondary_intelectuelles_tab2,
input.sheet-secondary_intelectuelles_tab3:checked ~ div.sheet-secondary_intelectuelles_tab3
{
display: block;
}
input.sheet-secondary_social_tab1:checked ~ div.sheet-secondary_social_tab1,
input.sheet-secondary_social_tab2:checked ~ div.sheet-secondary_social_tab2,
input.sheet-secondary_social_tab3:checked ~ div.sheet-secondary_social_tab3
{
display: block;
}
input.sheet-secondary_arsenal_tab1:checked ~ div.sheet-secondary_arsenal_tab1,
input.sheet-secondary_arsenal_tab2:checked ~ div.sheet-secondary_arsenal_tab2,
input.sheet-secondary_arsenal_tab3:checked ~ div.sheet-secondary_arsenal_tab3
{
display: block;
}input.sheet-tab{
-moz-appearance: none;
width:150px;
height: 20px;
top: 5px;
left: 6px;
margin: 5px;
cursor: pointer;
z-index: 1;
content: attr(title);
}
input.sheet-tab::before{
-moz-appearance: none;
content: attr(title);
border-radius:.5em;
border:2px solid black;
text-align: center;
display: inline-block;
background: black;
color:white;
width: 150px;
height: 20px;
font-size: 18px;
}
input.sheet-tab:checked::before{
-moz-appearance: none;
background:#CCCCCC;
color:black;
border-radius:.5em;
border:2px solid black;
}
input.sheet-small_tab{
-moz-appearance: none;
width:120px;
height: 20px;
cursor: pointer;
z-index: 1;
margin:5px;
}
input.sheet-small_tab::before{
-moz-appearance: none;
content: attr(title);
border-radius:.5em;
text-align: center;
display: inline-block;
color:white;
background:black;
border:2px solid black;
width: 120px;
height:20px;
font-size: 14px;
}
input.sheet-small_tab:checked::before{
-moz-appearance: none;
border:2px solid black;
background:#CCCCCC;
color:black;
border-radius:.5em;
}
input.sheet-skill_name{
-moz-appearance: none;
width:400px;
}
input.sheet-skill_hidden{
visibility: hidden;
}
div.sheet-tab-content{
border-top-color: #000;
margin: 2px 0 0 0;
}
select.sheet-skill_select{
width:55px;
margin-bottom:-1px;
}
select.sheet-dice_select{
width:85px;
margin-bottom:-1px;
}
.sheet-trait{
width: 30px;
}
.sheet-numberbox {
width: 50px;
}
.sheet-rolltemplate-d10init table,
.sheet-rolltemplate-d10skillcheck table {
border-radius: 6px;
width:100%;
padding:0px;
margin:0px;
padding: 2px;
border: 1px solid;
background-color: #ffffff;
border-width: 1px;
border-style: solid;
border-color: #000;
border-image-source: none;
}
.sheet-rolltemplate-d10init .sheet-roll-title,
.sheet-rolltemplate-d10init th,
.sheet-rolltemplate-d10skillcheck .sheet-roll-title,
.sheet-rolltemplate-d10skillcheck th {
color: rgb(42, 42, 42);
padding:0px;
margin:0px;
padding-left: 5px;
font-size: 1.2em;
text-align: left;
font-family: "Times New Roman", Times, serif;
font-variant: small-caps;
text-transform: capitalize;
border-width: 0px;
}
.sheet-rolltemplate-d10init .sheet-roll-attr,
.sheet-rolltemplate-d10skillcheck .sheet-roll-attr{
color: #555555;
font-size: 1em;
font-style: italic;
padding:0px;
margin:0px;
padding-left: 9px;
border-width: 0px;
margin-top: -10px;
}
.sheet-rolltemplate-d10init .sheet-roll-success,
.sheet-rolltemplate-d10skillcheck .sheet-roll-success ,
.sheet-rolltemplate-d10skillcheck .sheet-roll-fail {
padding:0px;
margin:0px;
border-width: 0px;
padding-left: 5px;
}
.sheet-rolltemplate-d10skillcheck .sheet-roll-crit {
padding:0px;
margin:0px;
border-width: 0px;
padding-left: 5px;
background-color:#b0d6ad;
}
.sheet-rolltemplate-d10skillcheck .sheet-roll-fumble {
padding-left: 5px;
border-width: 0px;
background-color:#d6adad;
}
.sheet-rolltemplate-d10init .sheet-inline,
.sheet-rolltemplate-d10init .inlinerollresult,
.sheet-rolltemplate-d10skillcheck .sheet-inline,
.sheet-rolltemplate-d10skillcheck .inlinerollresult {
background-color: transparent;
border: none;
font-weight: bold;
padding:0px;
font-family: "Times New Roman", Times, serif;
}
.sheet-rolltemplate-d10skillcheck .sheet-inline.sheet-fullcrit,
.sheet-rolltemplate-d10skillcheck .inlinerollresult.fullcrit {
color: #3FB315;
border: none;
}
.sheet-rolltemplate-d10skillcheck .sheet-inline.sheet-fullfail,
.sheet-rolltemplate-d10skillcheck .inlinerollresult.fullfail {
color: #B31515;
border: none;
}
.sheet-rolltemplate-d10skillcheck .inlinerollresult.importantroll {
color: #4A57ED;
border: none;
}
.sheet-rolltemplate-d10fight-blob{
border-radius: 6px;
border: 1px solid #898989;
z-index: 1;
}
.sheet-rolltemplate-d10fight table{
padding:0px;
margin:0px;
text-align: left;
width:100%;
border:none;
cellpadding:3px;
cellspacing:0px;
}
.sheet-rolltemplate-d10fight .sheet-sum{
padding:0px;
margin:0px;
border:none;
text-align: right;
padding-right:10px;
}
.sheet-rolltemplate-d10fight .sheet-success,
.sheet-rolltemplate-d10fight .sheet-line{
padding:0px;
margin:0px;
padding-left: 3px;
border:none;
}
.sheet-rolltemplate-d10fight .sheet-critical{
padding:0px;
margin:0px;
border:none;
padding-left: 3px;
border-radius: 4px;
background-color:#b0d6ad;
}
.sheet-rolltemplate-d10fight .sheet-hit{
padding:0px;
margin:0px;
padding-left: 3px;
border-radius: 4px;
background-color:#b0d6ad;
border:none;
}
.sheet-rolltemplate-d10fight .sheet-miss{
padding:0px;
margin:0px;
padding-left: 3px;
border:none;
border-radius: 4px;
background-color:#d6adad;
}
.sheet-rolltemplate-d10fight .sheet-name{
padding:0px;
padding-left: 3px;
margin:0px;
border:none;
border-radius: 4px;
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
background-color: #999999;
}
.sheet-rolltemplate-d10fight .sheet-additional{
padding:0px;
margin:0px;
border:none;
padding-left:10px;
}
.sheet-rolltemplate-d10fight-grey{
color: #999999;
}
.sheet-rolltemplate-d10fight-green{
color: #009900;
}
.sheet-rolltemplate-d10fight a,
.sheet-rolltemplate-d10fight a[href^="!"],
.sheet-rolltemplate-d10fight a[href^="~"]{
text-align:right;
background-color: #999999; !important
}
.sheet-rolltemplate-d10Shooting .sheet-container {
background-color: #ffffff;
border: 1px solid;
padding: 2px;
width: 189px;
}
.sheet-rolltemplate-d10Shooting .sheet-container h1 {
color: rgb(126, 45, 64);
font-size: 1.2em;
font-variant: small-caps;
line-height: 20px;
}
.sheet-rolltemplate-d10Shooting div {
padding: 2px;
};
.sheet-rolltemplate-d10Shooting span {
color: rgb(126, 45, 64);
font-family: "Times New Roman", Times, serif;
font-size: 1.2em;
font-variant: small-caps;
line-height: 1.6em;
padding-left: 5px;
text-align: left;
}
.sheet-rolltemplate-d10Shooting .sheet-subheader {
color: #000;
font-size: 1em;
font-style: italic;
}
.sheet-rolltemplate-d10Shooting .sheet-arrow-right {
border-bottom: 2px solid transparent;
border-left: 180px solid rgb(126, 45, 64);
border-top: 2px solid transparent;
}
.sheet-rolltemplate-d10Shooting .sheet-tcat {
font-style: italic;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult {
background-color: #ffffff;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.fullcrit {
color: #3FB315;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.fullfail {
color: #B31515;
border: none;
}
.sheet-rolltemplate-d10Shooting .inlinerollresult.importandivoll {
color: #4A57ED;
border: none;
}
select.sheet-weapon_type_select{
line-height: 0px;
margin-bottom:0px;
margin: 0px;
}
label {
display: inline;
margin: 0px;
padding: 0px;
}
div.sheet-row{
margin: 0px;
padding: 3px;
}
div.sheet-quickborder{
border: 1px solid #ccc;
border-color: grey;
margin:5px;
padding:5px;
}
div.repeating_ranged-weapon{
margin:5px;
}

File diff suppressed because it is too large Load Diff

215
helpers/tests.py Normal file
View File

@ -0,0 +1,215 @@
import minitest
import re
from skill_generator import *
__all__=["testParser","testWrapper","testInit","testReroll"]
class testInit(minitest.simpleTestUnit):
"""Check the initialisation message"""
def __init__(self):
super(testInit, self).__init__("initialisation variables")
def _testInit(self):
self.currentTest("generating test values")
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:
dict_list = {}
for l in list:
dict_list[l[0]] = l[6]
self.addSuccess()
except Exception as ex:
self.addFailure(str(ex))
self.currentTest("testing list")
if a < b:
pass # Only if the values are updated
# self.addFailure("Too many values in the list")
# for l in dict_list.keys():
# if l not in test_values:
# self.currentTest(l)
# self.addFailure("{} missing from the test template".format(l))
elif b < a:
self.addFailure("Too few values in the list")
for t, v in test_values.items():
if t not in dict_list.keys():
self.currentTest(t)
self.addFailure("Missing element {}".format(v))
else:
for l, vl in dict_list.items():
if l in test_values.keys():
if test_values[l] != vl:
self.currentTest(test_values[l])
self.addFailure("Expected {}, got {}".format(l, vl))
else:
self.currentTest(l)
self.addFailure("The element is not in the test values")
self.addSuccess()
class testReroll(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testReroll, self).__init__("inline message")
def _testReroll(self):
self.currentTest("regex generation")
model = """"var msg_relance="<a class='sheet-rolltemplate-d10fight' href='!crit 0 P "+d_vars.perfection+" I 1 "+d_vars.defense_i_0+" I 2 "+d_vars.defense_i_1+" I 4 "+d_vars.defense_i_2+" R "+d_vars.rempart_p+" F "+d_vars.fauchage+" E 1 "+d_vars.exploiter_p_0+" E 2 "+d_vars.exploiter_p_1+" E 4 "+d_vars.exploiter_p_2+" T 2 "+d_vars.tir_p_0+" T 4 "+d_vars.tir_p_1+" i "+d_vars.tir_i+" C "+d_vars.charge+" N "+d_vars.charge_i+" + "+(d_vars.nb_2add+d_vars.technique_result+d_vars.encaissement_result)+" - "+d_vars.nb_2sub+" r ?{Relances ?}"+" s "+d_vars.seuil+" a "+d_vars.action+" H "+d_vars.on_hit_c+" A "+d_vars.attribute+" L "+d_vars.replace+" l "+d_vars.add_to_all+" m "+d_vars.max_dices+" n "+d_vars.player_name;
for (var i=0,len=d_vars.results.length;i<len;i++) msg_relance+=" d "+d_vars.results[i];
msg_relance+="'>Relancer ce jet</a>";"""
var = re.compile(' ([a-zA-Z:+_] .*?".*?)(?:\+"|;)')
self.addSuccess()
self.currentTest('generating inline message')
roll = reroll(args)
self.addSuccess()
self.currentTest("checking generated roll")
for e in (var.findall(model)):
if roll.find(e) < 0:
self.currentTest("[{}]".format(e))
self.addFailure("missing value")
self.addSuccess()
# Only if the args are updated
# self.currentTest("checking model")
# for e in var.findall(roll):
# if model.find(e)<0:
# self.currentTest("[{}]".format(e))
# self.addFailure("missing value")
# self.addSuccess()
class testWrapper(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testWrapper, self).__init__("inline message")
def _testWrapper(self):
self.currentTest("generating wrapper")
s = len(hashedCategories)
errors=0
try:
wrapper[-1]
errors += 1
self.addFailure("Error: Element -1 shouldn't exist")
except:
self.addSuccess()
f = 0
self.currentTest("hashing categories")
for ele in wrapper:
for c in hashedCategories.keys():
if ele.__getattr__(c) != findCat(ele, c):
f += 1
self.currentTest(ele[0])
self.addFailure("{} found, should be {}".format(findCat(ele, c), ele.__getattr__(c)))
for i in range(s):
if wrapper[ele[0]][i] != ele.asList()[i] or wrapper[ele[0]][i] != ele[i]:
f += 1
self.currentTest(i)
self.addFailure("Element differs {}!={}".format(wrapper[ele[0]][i], ele.asList()[i]))
if f == 0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
f = 0
self.currentTest("single variable")
for i in wrapper.itersingles():
if i[0] not in wrapper:
f += 1
self.addFailure("{} element missing".format(i[0]), nonDestructive=True)
if f == 0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
f = 0
self.currentTest("double variables")
for l in wrapper.iterdoubles():
for i in l:
if i[0] not in wrapper:
f += 1
self.addFailure("{} element missing".format(i[0]), nonDestructive=True)
if f == 0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
class testParser(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testParser, self).__init__("inline message")
def _testParser(self):
self.currentTest("loading parser")
par = parser(args)
self.addSuccess()
f = 0
nb_code = 0
self.currentTest("testing all variables")
for line in list:
cat = findCat(line, "code")
if cat != "":
nb_code += 1
if 'case "{}"'.format(cat) not in par:
f += 1
self.addFailure("code {} not found".format(cat), nonDestructive=True)
if 'd_vars.{}'.format(findCat(line, "varname")) not in par:
f += 1
self.addFailure("variable {} not found".format(findCat(line, "varname")), nonDestructive=True)
if f == 0:
self.addSuccess()
else:
self.addFailure("{} failures".format(f))
self.currentTest("testing i++ count")
count = par.count("i+=")
nb_code = nb_code + len([l for l in wrapper.iterdoubles()]) - sum([len(l) for l in wrapper.iterdoubles()])
if count != nb_code:
self.addFailure("{} occurences found (expected {})".format(par.count("i+="), nb_code))
else:
self.addSuccess()
self.currentTest("counting {}")
counto = par.count("{")
countc = par.count("}")
tot = len([l for l in wrapper.iterdoubles()]) + 3
if counto != countc or counto != tot:
self.addFailure("found {} '{{' and {} '}} ' instead of {}".format(counto, countc, tot))
else:
self.addSuccess()
f = 0
self.currentTest("checking special text")
for line in list:
cat = findCat(line, "parser")
if cat:
for l in cat.splitlines():
if l not in par:
self.addFailure("{} isn't in the end result".format(l), nonDestructive=True)
if f == 0:
self.addSuccess()
else:
self.addFailure("{} failures".format(f))
"""for varname with symbol, find symbol
for Special text, find special
"""
term = minitest.Terminal()

View File

@ -1,600 +0,0 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Not actually part of the project; just easier to maintain everything here
import sys,os,traceback
import re
try:
from minitest import minitest
term=minitest.Terminal()
except:
pass
try:
args=sys.argv[1:]
command=sys.argv[1]
except:
print("No command specified, just outputing the help")
command="help"
EOL="\n"
tab=" "
#Custom parsing
ENCAISSEMENT_PARSE="""d_vars.encaissement=to_number(tab[i+1]);
d_vars.encaissement_dices="d20";
if (tab[i+2]=="4") d_vars.encaissement_dices="d10";
i+=3;
break;"""
FLAT_DICES_PARSE="""d_vars.flat_dices[d_vars.nb_flat_dices]=to_p_number(tab[i+1]);
d_vars.nb_flat_dices++;
i+=2;
break;"""
TECHNIQUE_PARSE="""d_vars.technique_m=to_p_number(tab[i+2]);
i+=3;
break;"""
## Custom adders:
lambda_flat_dices=lambda a: "@flat_dices[@flat_dices]=type({tab+1});\n@nb_flat_dices++;"
## Custom rerolls:
categories=['varname','Pretty name','nb_args','type','code','id','default','action','parser']
hashedCategories={}
for c in range(len(categories)):
hashedCategories[categories[c]]=c
def findCat(element,category):
return element[hashedCategories[category]]
list=[]
#list.append(['varname','Pretty name','nb_args','type','code','id','default','action','parser'])
list.append(['perfection','Perfection',1,'pint','P',0,0,"",None])
list.append(['defense_i_0','Defence impénétrable simple',2,'pint','I',1,0,"",None])
list.append(['defense_i_1','Defence impénétrable expert',2,'pint','I',2,0,"",None])
list.append(['defense_i_2','Defence impénétrable meta',2,'pint','I',4,0,"",None])
list.append(['rempart_p','Rempart parfait',1,'pint','R',0,0,"",None])
list.append(['technique_m','Perfection',1,'pint','M',0,0,"",TECHNIQUE_PARSE]) #+=3
list.append(['coup_d','Coup_déchirant',1,'pint','D',0,0,"",None])
list.append(['fauchage','Fauchage',1,'pint','F',0,0,"",None])
list.append(['exploiter_p_0','Exploiter_les_points_faibles simple',2,'pint','E',1,0,"",None])
list.append(['exploiter_p_1','Exploiter_les_points_faibles expert',2,'pint','E',2,0,"",None])
list.append(['exploiter_p_2','Exploiter_les_points_faibles meta',2,'pint','E',4,0,"",None])
list.append(['tir_p_0','Tir_précis expert',2,'pint','T',2,0,"",None])
list.append(['tir_p_1','Tir_précis meta',2,'pint','T',4,0,"",None])
list.append(['tir_i','Tir_implacable',1,'pint','i',0,0,"",None])
list.append(['charge','Charge',1,'pint','C',0,0,"",None])
list.append(['charge_i','Charge_indomptable',1,'pint','N',0,0,"",None])
list.append(['nb_2add','Nombre à ajouter',1,'int','+',0,0,"+",None])
list.append(['nb_2sub','Nombre a soustraire',1,'int','-',0,0,"+",None])
list.append(['relances','Relances',1,'pint','r',0,0,"",None])
list.append(['seuil','Seuil',1,'pint','s',0,0,"",None])
list.append(['action','Type d\'Action',1,'str','a',0,'""',"",None])
list.append(['flat_dices','Des fixes',1,'pint','d',0,"[]","+",FLAT_DICES_PARSE])
list.append(['on_hit_c','Dégats a l\'impact critique',1,'int','H',0,0,"+",None])
list.append(['attribute','Caractéristique',1,'int','A',0,0,"+",None])
list.append(['encaissement','Encaissement',1,'pint','S',0,0,"",ENCAISSEMENT_PARSE]) # It's actually 2 args but no switch
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','n',0,'""',"",None])
list.append(['crit_level','Niveau de critique',1,'pint','c',0,2,"",None])
list.append(['transcendence','Transcendence',1,'pint','t',0,3,"",None])
list.append(['pctreceived','Pourcentage dégats recus',1,'int','v',0,0,"",None])
list.append(['pctinflicted','Pourcentage dégats infligés',1,'int','f',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])
list.append(['encaissement_dices','Perfection',1,'pint','',0,'""',"",None])
list.append(['results','Resultats',1,'pint','',0,"[]","",None])
list.append(['cleave','Fauchage',1,'pint','',0,"[]","",None])
list.append(['encaissement_result','Resultat d\'encaissement',1,'pint','',0,0,"",None])
list.append(['technique_result','Dégats technique martiale',1,'int','',0,0,"",None])
list.append(['coup_d_results','Coup déchirant results',1,'pint','',0,"[]","",None])
class megaListWrapper():
def __init__(self,table=list):
self.table=table
self.len=len(table)
self.indexes={}
for i in range(len(table)):
self.indexes[findCat(table[i],"varname")]=i
# Theese are array because you can't acess them directly
self.singles=[]
self.code=[]
self.doubles={}
for i in table:
if findCat(i,'nb_args')==1:
self.singles.append(i)
elif findCat(i,'nb_args')==2:
n=findCat(i,'code')
if n not in self.doubles:
self.doubles[n]=[]
self.doubles[n].append(i)
if findCat(i,'code')!='':
self.code.append(i)
def __getitem__(self,argument): #Actually return the full line as a list wrapper
return listWrapper(self.table[self.indexes[argument]])
def __iter__(self):
for index,key in self.indexes.items():
yield self[index]
def itersingles(self):
"Only iterate over the simple argument ones"
for index in self.singles:
yield self[findCat(index,'varname')]
def iterdoubles(self):
"Only iterate over the double arguments ones return a table with all"
for table in self.doubles.values():
yield [self[findCat(l,'varname')] for l in table]
def iterdefined(self):
"Only iterate over the ones with defined code"
pass
def __contains__(self,val):
return val in self.indexes
def __len__(self):
return self.len
def pprint(self):
for e in self:
print(e[0],":",e)
class listWrapper():
def __init__(self,list,index=hashedCategories):
self.list=list
self.indexes=index
def pprint(self):
print(self.list)
def asList(self):
return self.list
def __len__(self):
return len(self.list)
def __repr__(self):
return str(self.list)
def __getitem__(self,nb):
return self.list[nb]
def __getattr__(self,index):
return self.list[self.indexes[index]]
def __iter__(self):
for e in self.list:
yield e
## Commands
def initialise(args):
"Initialise the variables for the switch"
text="var d_vars={"
for line in list:
text+='"{}":{},'.format(line[0],line[6])
text=text[:-1]+'};'
return text
def pprint(args):
"Print the whole list of values"
for i in list:
print(i)
def pErrors(name,errors):
"Print sucess or error of given test"
if errors:
print("{:<15}: {} errors occured".format(name,errors))
else:
print("{:<15}: All test sucessful".format(name))
return errors
def reroll(args):
"Generate the reroll inline message"
reroll="var msg_relance=\"<a class='sheet-rolltemplate-d10fight' href='!crit 0"
def addZero(name):
return '"+d_vars.{}+"'.format(name)
def addOne(code,name):
return ' {} {}'.format(code,addZero(name))
def addTwo(code,id,name):
return ' {} {} {}'.format(code,id,addZero(name))
def addSimple(wline):
if wline.code!="" and wline.code not in ("r","+",'M','D',"d","S"):
if wline.nb_args==1:
return addOne(wline.code,wline.varname)
elif wline.nb_args==2:
return addTwo(wline.code,wline.id,wline.varname)
else:
#print("{} must be handled differently".format(wline.varname))
return ""
# Actual adding of all the lines
for l in wrapper:
reroll+=addSimple(l)
# Some lines needs to be added afterwards
reroll+=' + "+(d_vars.{}+d_vars.{}+d_vars.{})'.format(wrapper["nb_2add"].varname, wrapper["technique_result"].varname, wrapper["encaissement_result"].varname)
# Last part of the command
reroll+='+" r ?{Relances ?}";\n'
reroll+='for (var i=0,len=d_vars.results.length;i<len;i++) msg_relance+=" d "+d_vars.results[i];\n'
reroll+='msg_relance+="\'>Relancer ce jet</a>";'
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:
if len(listFree)==1:
return 'The code "{}" is available.'.format(listFree)
else:
return 'The following 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"
res=tab+"if (len_args>0){"+EOL
res+=tab*2+"d_vars.nb_dices=to_p_number(tab[0]);"+EOL
res+=tab+"}"+EOL
res+=tab+"for (i = 1; i < len_args;) {"+EOL
res+=tab*2+"switch(tab[i]) {"+EOL
def typewise(type):
if type=="pint":
return "to_p_number({});"
elif type=='int':
return "to_number({});"
return "{};"
doubles={}
for elt in wrapper.itersingles():
if elt.parser:
res+=tab*3+'case "{}":'.format(elt.code)+EOL
for l in elt.parser.splitlines():
res+=tab*4+l+EOL
elif elt.code!="":
res+=tab*3+'case "{}":'.format(elt.code)+EOL
res+=tab*4+'d_vars.{}{}={}'.format(elt.varname,elt.action,typewise(elt.type).format("tab[i+1]"))+EOL
res+=tab*4+'i+=2;'+EOL
res+=tab*4+'break;'+EOL
for grp in wrapper.iterdoubles():
res+=tab*3+'case "{}":'.format(grp[0].code)+EOL
res+=tab*4+'switch (tab[i+1]) {'+EOL
for elt in grp:
if elt.parser:
for l in elt.parser.splitlines():
res+=tab*5+l+EOL
elif elt.code!="":
res+=tab*5+'case "{}":'.format(elt.id)+EOL
res+=tab*6+'d_vars.{}{}={}'.format(elt.varname,elt.action,typewise(elt.type).format("tab[i+2]"))+EOL
res+=tab*6+'break;'+EOL
if not elt.parser:
res+=tab*4+"}"+EOL
res+=tab*4+'i+=3;'+EOL
res+=tab*4+'break;'+EOL
res+=tab*3+"default:"+EOL
res+=tab*4+'logit("Argument "+tab[i]+" unknown.");'+EOL
res+=tab*4+"i++;"+EOL
res+=tab*4+"break;"+EOL
res+=tab*2+"}"+EOL
res+=tab*1+"}"+EOL
return res
class testInit(minitest.simpleTestUnit):
"""Check the initialisation message"""
def __init__(self):
super(testInit, self).__init__("initialisation variables")
def _testInit(self):
self.currentTest("generating test values")
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:
dict_list={}
for l in list:
dict_list[l[0]]=l[6]
self.addSuccess()
except Exception as ex:
self.addFailure(str(ex))
self.currentTest("testing list")
if a<b:
pass # Only if the values are updated
# self.addFailure("Too many values in the list")
# for l in dict_list.keys():
# if l not in test_values:
# self.currentTest(l)
# self.addFailure("{} missing from the test template".format(l))
elif b<a:
self.addFailure("Too few values in the list")
for t,v in test_values.items():
if t not in dict_list.keys():
self.currentTest(t)
self.addFailure("Missing element {}".format(v))
else:
for l,vl in dict_list.items():
if l in test_values.keys():
if test_values[l]!=vl:
self.currentTest(test_values[l])
self.addFailure("Expected {}, got {}".format(l,vl))
else:
self.currentTest(l)
self.addFailure("The element is not in the test values")
self.addSuccess()
class testReroll(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testReroll, self).__init__("inline message")
def _testReroll(self):
self.currentTest("regex generation")
model=""""var msg_relance="<a class='sheet-rolltemplate-d10fight' href='!crit 0 P "+d_vars.perfection+" I 1 "+d_vars.defense_i_0+" I 2 "+d_vars.defense_i_1+" I 4 "+d_vars.defense_i_2+" R "+d_vars.rempart_p+" F "+d_vars.fauchage+" E 1 "+d_vars.exploiter_p_0+" E 2 "+d_vars.exploiter_p_1+" E 4 "+d_vars.exploiter_p_2+" T 2 "+d_vars.tir_p_0+" T 4 "+d_vars.tir_p_1+" i "+d_vars.tir_i+" C "+d_vars.charge+" N "+d_vars.charge_i+" + "+(d_vars.nb_2add+d_vars.technique_result+d_vars.encaissement_result)+" - "+d_vars.nb_2sub+" r ?{Relances ?}"+" s "+d_vars.seuil+" a "+d_vars.action+" H "+d_vars.on_hit_c+" A "+d_vars.attribute+" L "+d_vars.replace+" l "+d_vars.add_to_all+" m "+d_vars.max_dices+" n "+d_vars.player_name;
for (var i=0,len=d_vars.results.length;i<len;i++) msg_relance+=" d "+d_vars.results[i];
msg_relance+="'>Relancer ce jet</a>";"""
var=re.compile(' ([a-zA-Z:+_] .*?".*?)(?:\+"|;)')
self.addSuccess()
self.currentTest('generating inline message')
roll=reroll(args)
self.addSuccess()
self.currentTest("checking generated roll")
for e in (var.findall(model)):
if roll.find(e)<0:
self.currentTest("[{}]".format(e))
self.addFailure("missing value")
self.addSuccess()
# Only if the args are updated
#self.currentTest("checking model")
#for e in var.findall(roll):
# if model.find(e)<0:
# self.currentTest("[{}]".format(e))
# self.addFailure("missing value")
#self.addSuccess()
class testWrapper(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testWrapper, self).__init__("inline message")
def _testWrapper(self):
self.currentTest("generating wrapper")
s=len(hashedCategories)
try:
wrapper[-1]
errors+=1
self.addFailure("Error: Element -1 shouldn't exist")
except:
self.addSuccess()
f=0
self.currentTest("hashing categories")
for ele in wrapper:
for c in hashedCategories.keys():
if ele.__getattr__(c)!=findCat(ele,c):
f+=1
self.currentTest(ele[0])
self.addFailure("{} found, should be {}".format(findCat(ele,c),ele.__getattr__(c)))
for i in range(s):
if wrapper[ele[0]][i]!=ele.asList()[i] or wrapper[ele[0]][i]!=ele[i]:
f+=1
self.currentTest(i)
self.addFailure("Element differs {}!={}".format(wrapper[ele[0]][i],ele.asList()[i]))
if f==0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
f=0
self.currentTest("single variable")
for i in wrapper.itersingles():
if i[0] not in wrapper:
f+=1
self.addFailure("{} element missing".format(i[0]),nonDestructive=True)
if f==0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
f=0
self.currentTest("double variables")
for l in wrapper.iterdoubles():
for i in l:
if i[0] not in wrapper:
f+=1
self.addFailure("{} element missing".format(i[0]),nonDestructive=True)
if f==0:
self.addSuccess()
else:
self.addFailure("{} elements failed".format(f))
class testParser(minitest.simpleTestUnit):
"""Check the reroll inline message"""
def __init__(self):
super(testParser, self).__init__("inline message")
def _testParser(self):
self.currentTest("loading parser")
par=parser(args)
self.addSuccess()
f=0
nb_code=0
self.currentTest("testing all variables")
for line in list:
cat=findCat(line,"code")
if cat!="":
nb_code+=1
if 'case "{}"'.format(cat) not in par:
f+=1
self.addFailure("code {} not found".format(cat),nonDestructive=True)
if 'd_vars.{}'.format(findCat(line,"varname")) not in par:
f+=1
self.addFailure("variable {} not found".format(findCat(line,"varname")),nonDestructive=True)
if f==0:
self.addSuccess()
else:
self.addFailure("{} failures".format(f))
self.currentTest("testing i++ count")
count=par.count("i+=")
nb_code=nb_code+len([l for l in wrapper.iterdoubles()])-sum([len(l) for l in wrapper.iterdoubles()])
if count!=nb_code:
self.addFailure("{} occurences found (expected {})".format(par.count("i+="),nb_code))
else:
self.addSuccess()
self.currentTest("counting {}")
counto=par.count("{")
countc=par.count("}")
tot=len([l for l in wrapper.iterdoubles()])+3
if counto!=countc or counto!=tot:
self.addFailure("found {} '{{' and {} '}} ' instead of {}".format(counto,countc,tot))
else:
self.addSuccess()
f=0
self.currentTest("checking special text")
for line in list:
cat=findCat(line,"parser")
if cat:
for l in cat.splitlines():
if l not in par:
self.addFailure("{} isn't in the end result".format(l),nonDestructive=True)
if f==0:
self.addSuccess()
else:
self.addFailure("{} failures".format(f))
"""for varname with symbol, find symbol
for Special text, find special
"""
def test_all(args):
"Execute all tests"
subclass=minitest.testGroup("Main Classes",term,verbose=True)
all_s,t=["reroll","init","wrapper","parser"],0
if len(args)>1:
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 export(args):
if len(args)>1:
filen=args[1]
try:
f=open(filen)
except:
filen="export.log"
f=open(filen,"w+")
def title(t):
return "{} {} {}".format("#"*10,t,"#"*10)+EOL
f.write(title("Relances"))
f.write(reroll([])+EOL)
f.write(title("Reroll"))
f.write(initialise([])+EOL)
f.write(title("Parse"))
f.write(parser([])+EOL)
f.close()
return "All data written in '{}'".format(filen)
def help(args):
"Help, print the following message"
print("List of availables commands")
for key in commands.keys():
print(" {}: {}".format(key,commands[key].__doc__))
commands={"init":initialise,"print":pprint,"reroll":reroll,
"test":test_all,"code":find_code,"parser":parser,"export":export,"help":help}
if __name__ == '__main__':
wrapper=megaListWrapper()
try:
ret=commands[command](args)
if ret:
print(ret)
except KeyError:
print("Command {} doesn't exist".format(command))
commands['help'](args)
except Exception:
print("Couldn't execute command "+command)
print(" > {} ({})".format(sys.exc_info()[1],sys.exc_info()[0]))
traceback.print_tb(sys.exc_info()[2])

View File

@ -4,28 +4,32 @@ input.sheet-tab2:checked ~ div.sheet-tab2,
input.sheet-tab3:checked ~ div.sheet-tab3 input.sheet-tab3:checked ~ div.sheet-tab3
{ {
display: block; display: block;
}
input.sheet-secondary_tab1:checked ~ div.sheet-secondary_tab1, div.sheet-header-tab-content { display: none; }
input.sheet-secondary_tab2:checked ~ div.sheet-secondary_tab2, input.sheet-header-tab1:checked ~ div.sheet-header-tab1,
input.sheet-secondary_tab3:checked ~ div.sheet-secondary_tab3, input.sheet-header-tab2:checked ~ div.sheet-header-tab2,
input.sheet-secondary_tab4:checked ~ div.sheet-secondary_tab4,
input.sheet-secondary_tab5:checked ~ div.sheet-secondary_tab5
{ {
display:block; display: block;
} }
input.sheet-secondary_magic_tab1:checked ~ div.sheet-secondary_magic_tab1,
input.sheet-secondary_magic_tab2:checked ~ div.sheet-secondary_magic_tab2, input.sheet-secondary_physique_tab1:checked ~ div.sheet-secondary_physique_tab1,
input.sheet-secondary_magic_tab3:checked ~ div.sheet-secondary_magic_tab3, input.sheet-secondary_physique_tab2:checked ~ div.sheet-secondary_physique_tab2,
input.sheet-secondary_magic_tab4:checked ~ div.sheet-secondary_magic_tab4, input.sheet-secondary_physique_tab3:checked ~ div.sheet-secondary_physique_tab3,
input.sheet-secondary_magic_tab5:checked ~ div.sheet-secondary_magic_tab5 input.sheet-secondary_physique_tab4:checked ~ div.sheet-secondary_physique_tab4
{ {
display:block; display: block;
} }
input.sheet-secondary_skills_tab1:checked ~ div.sheet-secondary_skills_tab1, input.sheet-secondary_intelectuelles_tab1:checked ~ div.sheet-secondary_intelectuelles_tab1,
input.sheet-secondary_skills_tab2:checked ~ div.sheet-secondary_skills_tab2, input.sheet-secondary_intelectuelles_tab2:checked ~ div.sheet-secondary_intelectuelles_tab2,
input.sheet-secondary_skills_tab3:checked ~ div.sheet-secondary_skills_tab3 input.sheet-secondary_intelectuelles_tab3:checked ~ div.sheet-secondary_intelectuelles_tab3
{ {
display:block; display: block;
}
input.sheet-secondary_social_tab1:checked ~ div.sheet-secondary_social_tab1,
input.sheet-secondary_social_tab2:checked ~ div.sheet-secondary_social_tab2,
input.sheet-secondary_social_tab3:checked ~ div.sheet-secondary_social_tab3
{
display: block;
} }
input.sheet-tab{ input.sheet-tab{
@ -155,8 +159,8 @@ select.sheet-dice_select{
border-width: 0px; border-width: 0px;
margin-top: -10px; margin-top: -10px;
} }
.sheet-rolltemplate-d10init .sheet-roll-sucess, .sheet-rolltemplate-d10init .sheet-roll-success,
.sheet-rolltemplate-d10skillcheck .sheet-roll-sucess , .sheet-rolltemplate-d10skillcheck .sheet-roll-success ,
.sheet-rolltemplate-d10skillcheck .sheet-roll-fail { .sheet-rolltemplate-d10skillcheck .sheet-roll-fail {
padding:0px; padding:0px;
margin:0px; margin:0px;
@ -223,7 +227,7 @@ select.sheet-dice_select{
text-align: right; text-align: right;
padding-right:10px; padding-right:10px;
} }
.sheet-rolltemplate-d10fight .sheet-sucess, .sheet-rolltemplate-d10fight .sheet-success,
.sheet-rolltemplate-d10fight .sheet-line{ .sheet-rolltemplate-d10fight .sheet-line{
padding:0px; padding:0px;
margin:0px; margin:0px;

View File

@ -1,197 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
var raw_msg = "4 P 2 I 4 2 E 4 1 T 1 4 + 11 - 22";
/*var nb_dices=0;
var perfection=0; //P
var defense_i_0=0; // I_1
var defense_i_1=0; // I_2
var defense_i_2=0; // I_4
var rempart_p=0; //R
var technique_m_0=0; //M_1
var technique_m_1=0; //M_2
var coup_d=0; //D
var fauchage=0; //F
var exploiter_p_0=0; //E_1
var exploiter_p_1=0; //E_2
var exploiter_p_2=0; //E_4
var tir_p_0=0; //T_1
var tir_p_1=0; //T_2
var tir_i=0; // O
var charge=0; //C
var charge_i=0; //N
var nb_2add=0; //+
var nb_2sub=0; //-
var replace=-1; //P
var add_to_all=0; //A
*/
// Internal Variables
logit("Parsing : "+raw_msg);
d_vars=parse_command(raw_msg);
/*
logit("nb_dices : " + d_vars.nb_dices);
logit("perfection : " + d_vars.perfection); //P
logit("defense_i_0 : " + d_vars.defense_i_0); // I_1
logit("defense_i_1 : " + d_vars.defense_i_1); // I_2
logit("defense_i_2 : " + d_vars.defense_i_2); // I_4
logit("rempart_p : " + d_vars.rempart_p); //R
logit("technique_m_0 : " + d_vars.technique_m_0); //M_1
logit("technique_m_1 : " + d_vars.technique_m_1); //M_2
logit("coup_d : " + d_vars.coup_d); //D
logit("fauchage : " + d_vars.fauchage); //F
logit("exploiter_p_0 : " + d_vars.exploiter_p_0); //E_1
logit("exploiter_p_1 : " + d_vars.exploiter_p_1); //E_2
logit("exploiter_p_2 : " + d_vars.exploiter_p_2); //E_4
logit("tir_p_0 : " + d_vars.tir_p_0); //T_1
logit("tir_p_1 : " + d_vars.tir_p_1); //T_2
logit("tir_i : " + d_vars.tir_i); // O
logit("charge : " + d_vars.charge); //C
logit("charge_i : " + d_vars.charge_i); //N
logit("+ " + d_vars.nb_2add);
logit("- " + d_vars.nb_2sub);
logit("+ " + d_vars.replace); //P
logit("+ " + d_vars.var add_to_all); //A*/
function to_number(nb){
var tmp=Number(nb);
if (isNaN(tmp)) return 0;
return tmp;
}
function parse_command(message){
var d_vars={"nb_dices":0,"perfection":0,"defense_i_0":0,"defense_i_1":0,"defense_i_2":0,"rempart_p":0,
"technique_m_0":0,"technique_m_1":0,"coup_d":0,"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};
var tab=message.split(" ");
var len_args=tab.length;
var i;
//logit(tab);
//logit(tab.length);
if (len_args>0){
d_vars.nb_dices=tab[0];
}
for (i = 1; i < tab.length;) {
switch(tab[i]) {
case "+":
d_vars.nb_2add=to_number(tab[i+1]);
i+=2;
break;
case "-":
d_vars.nb_2sub=to_number(tab[i+1]);
i+=2;
break;
case "P":
d_vars.perfection=to_number(tab[i+1]);
i+=2;
break;
case "I":
switch (tab[i+1]) {
case "1":
d_vars.defense_i_0=to_number(tab[i+2]);
break;
case "2":
d_vars.defense_i_1=to_number(tab[i+2]);
break;
case "4":
d_vars.defense_i_2=to_number(tab[i+2]);
break;
}
i+=3;
break;
case "E":
switch (tab[i+1]) {
case "1":
d_vars.exploiter_p_0=to_number(tab[i+2]);
break;
case "2":
d_vars.exploiter_p_1=to_number(tab[i+2]);
break;
case "4":
d_vars.exploiter_p_2=to_number(tab[i+2]);
break;
}
i+=3;
break;
case "T":
switch (tab[i+1]) {
case "1":
d_vars.tir_p_0=to_number(tab[i+2]);
break;
case "2":
d_vars.tir_p_1=to_number(tab[i+2]);
break;
}
i+=3;
break;
case "R":
d_vars.rempart_p=to_number(tab[i+1]);
i+=2;
break;
case "C":
d_vars.charge=to_number(tab[i+1]);
i+=2;
break;
case "M":
switch (tab[i+1]) {
case "1":
d_vars.technique_m_0=to_number(tab[i+2]);
break;
case "2":
d_vars.technique_m_1=to_number(tab[i+2]);
break;
}
i+=3;
break;
case "D":
d_vars.coup_d=to_number(tab[i+1]);
i+=2;
break;
case "F":
d_vars.fauchage=to_number(tab[i+1]);
i+=2;
break;
case "N":
d_vars.charge_i=to_number(tab[i+1]);
i+=2;
break;
case "O":
d_vars.tir_i=to_number(tab[i+1]);
i+=2;
break;
case "r":
d_vars.relance=to_number(tab[i+1]);
i+=2;
break;
default:
logit("Argument "+tab[i]+" unknown.");
i++;
}
}
return d_vars;
}
function logit(txt){
//Due to the incomprehensible restriction of console. in roll20
console.log(txt);
}
</script>
</head>
<body>
</body>
</html>