Fist Commit

This commit is contained in:
Dandaedre 2024-03-24 21:32:50 +01:00
commit 3bea80f6b5
12 changed files with 986 additions and 0 deletions

2
.cargo/config.toml Normal file
View File

@ -0,0 +1,2 @@
[build]
rustflags = ["-Clink-arg=-fuse-ld=mold", "-Zthreads=24", "-Ctarget-cpu=native"]

3
.config.toml Normal file
View File

@ -0,0 +1,3 @@
[build]
rustflags = ["-Z", "threads=8"]

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

146
Cargo.lock generated Normal file
View File

@ -0,0 +1,146 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "indexmap"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "memchr"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "proc-macro2"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rust20_d10"
version = "0.1.0"
dependencies = [
"serde",
"toml",
]
[[package]]
name = "serde"
version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_spanned"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
dependencies = [
"serde",
]
[[package]]
name = "syn"
version = "2.0.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "toml"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.22.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4"
dependencies = [
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "winnow"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8"
dependencies = [
"memchr",
]

20
Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
cargo-features = ["codegen-backend"]
[package]
name = "rust20_d10"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0.197", features = ["derive"] }
toml = "0.8.12"
[profile.dev]
debug = 0
codegen-backend = "cranelift"
[profile.release]
lto = true
codegen-units = 1
panic = "abort"

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# rust20_d10
rust20_d10 is a character sheet generator for tabletop role-playing games (TTRPGs) for the roll20 website.
This project is written in Rust, aiming for efficiency, reliability, and speed.
# Usage
rust20_d10

682
data/cyberpunk.toml Normal file
View File

@ -0,0 +1,682 @@
[config]
[data]
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-header-content">
<div class="sheet-centered-l">
<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-centered-r">
<h4 class="sheet-center">Des Utilisé :</h4>
<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>
</div>
</div>
<div class='sheet-2colrow'>
<input type="radio" name="attr_main_tab" class="sheet-tab sheet-main_tab1" value="1" title="Caractéristiques" checked="checked"/><span></span>
<input type="radio" name="attr_main_tab" class="sheet-tab sheet-main_tab2" value="2" title="Santé" /><span></span>
<input type="radio" name="attr_main_tab" class="sheet-tab sheet-main_tab3" value="3" title="Armure" /><span></span>
<div class="sheet-tab-content sheet-main_tab1">
<div class='sheet-col'>
<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'>
<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>Accreditation</td>
<td><input type="number" class="sheet-trait" name="attr_base-Accred" title="Accreditation de base" value="0" min="0" max="10"/></td>
<td><input type="number" class="sheet-trait" name="attr_exal-Accred" title="Modificateur" value="0"/></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Accreditation}} {{dice_name=@{dice}}} {{result=[[(@{base-Accred}+@{exal-Accred})*2-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Accred}+@{exal-Accred})*2]]}}"></button></td>
<td><button type='roll' class="sheet-trait_roll" value="&{template:d10skillcheck}{{name=@{character_name}}} {{roll_name=Accreditation}} {{dice_name=@{dice}}} {{result=[[(@{base-Accred}+@{exal-Accred})-d@{dice}cs1cf@{dice}]]}} {{threshold=[[(@{base-Accred}+@{exal-Accred})]]}}">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>
<div class="sheet-tab-content sheet-main_tab2">
<div class="sheet-imagecontainer">
<img src="https://raw.githubusercontent.com/Cocobug/sys_d10/cuberpunk/clean/robotman_health_r.png" alt="armor" height="300px">
<div class="sheet-head_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_head" title="Force-1" value="0"/></div>
<div class="sheet-body_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_body" title="Force+1" value="0"/></div>
<div class="sheet-left_arm_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_left_arm" title="Force" value="0"/></div>
<div class="sheet-right_arm_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_right_arm" title="Force" value="0"/></div>
<div class="sheet-left_leg_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_left_leg" title="Force" value="0"/></div>
<div class="sheet-right_leg_hp"><input type="number" class="sheet-body_values" name="attr_Life_Points_right_leg" title="Force" value="0"/></div>
</div>
</div>
<div class="sheet-tab-content sheet-main_tab3">
<div class="sheet-imagecontainer">
<img src="https://raw.githubusercontent.com/Cocobug/sys_d10/cuberpunk/clean/robotman_armor_r.png" alt="armor" height="300px">
<div class="sheet-head_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Protection_Points_head" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_head" title="Intégrité" value="0"/>
</div>
<div class="sheet-body_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Protection_Points_body" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_body" title="Intégrité" value="0"/>
</div>
<div class="sheet-left_arm_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Protection_Points_left_arm" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_left_arm" title="Intégrité" value="0"/>
</div>
<div class="sheet-right_arm_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Protection_Points_right_arm" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_right_arm" title="Intégrité" value="0"/>
</div>
<div class="sheet-left_leg_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Protection_Points_left_leg" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_left_leg" title="Intégrité" value="0"/>
</div>
<div class="sheet-right_leg_hp">
<input type="number" class="sheet-body_values" name="attr_Armor_Points_Protection_right_leg" title="Protection" value="0"/>
<input type="number" class="sheet-body_values" name="attr_Armor_Integrity_Points_right_leg" title="Intégrité" value="0"/>
</div>
</div>
</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 = """
.sheet-header-content {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
"sheet-centered-l sheet-centered-r";
}
.sheet-centered-l { grid-area: sheet-centered-l; }
.sheet-centered-r { grid-area: sheet-centered-r; }
div.sheet-main_tab-content { display: none; }
input.sheet-main_tab1:checked ~ div.sheet-main_tab1,
input.sheet-main_tab2:checked ~ div.sheet-main_tab2,
input.sheet-main_tab3:checked ~ div.sheet-main_tab3,
{
display: block;
}
.sheet-imagecontainer{
display: inline-block;
position: relative;
}
.sheet-head_hp {
position: absolute;
top: 7px;
left: 50px;
}
.sheet-body_hp {
position: absolute;
top: 59px;
left: 49px;
}
.sheet-left_arm_hp {
position: absolute;
top: 104px;
left: 11px;
}
.sheet-right_arm_hp {
position: absolute;
top: 104px;
left: 88px;
}
.sheet-left_leg_hp {
position: absolute;
top: 208px;
left: 18px;
}
.sheet-right_leg_hp {
position: absolute;
top: 208px;
left: 83px;
}
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: textfield;
width:400px;
}
input.sheet-skill_level{
-moz-appearance: textfield;
width:2.5em; !important;
}
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: 25px !important;
-moz-appearance: textfield;
}
.sheet-body_values{
width: 25px !important;
-moz-appearance: textfield;
}
.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;
}
"""

21
src/data_structure.rs Normal file
View File

@ -0,0 +1,21 @@
//! # Data Structure Module
//!
//! The `data_structure` module provides data structures for representing the loaded sections of a character or a model.
use serde::Deserialize;
#[derive(Deserialize)]
pub struct GlobalConfig {
config: Config,
data: Data,
}
#[derive(Deserialize)]
struct Data {
head: String,
script: String,
header: String,
css_footer: String,
}
#[derive(Deserialize)]
struct Config {}

3
src/export.rs Normal file
View File

@ -0,0 +1,3 @@
//! # Export Module
//!
//! The `export` module provides functionality to export a character sheet into an HTML template.

3
src/generator.rs Normal file
View File

@ -0,0 +1,3 @@
//! # Generator Module
//!
//! The `generator` module provides functionality for generating the final HTML from the loaded data and model.

89
src/loader.rs Normal file
View File

@ -0,0 +1,89 @@
//! # Loader Module
//!
//! The `loader` module provides functionality for loading a specific model file and handling IO operations and errors.
use std::{borrow::Borrow, fs, io, path::Path};
use crate::data_structure::GlobalConfig;
/// Represents an error during Loading
#[derive(Debug)]
pub enum LoadError {
/// Indicate an IOError occured
Io(io::Error),
/// Indicate the file format is invalid
InvalidFormat,
}
/// Represents a model once loaded
pub struct SheetModel {
config: Option<GlobalConfig>,
}
impl SheetModel {
/// Create a new SheetModel
pub fn new() -> SheetModel {
SheetModel { config: None }
}
/// Loads a model file from the specified path.
///
/// # Arguments
///
/// * `path` - A reference to the path of the model file to load.
///
/// # Returns
///
/// A Result asserting if the loading was sucessful or a LoadError if an error occurs.
///
/// # Examples
///
/// ```
/// use rust20_d10::loader::ModelLoader;
///
/// let loader = ModelLoader::new();
/// match loader.load_model("path/to/model_file.txt") {
/// Ok(model_data) => println!("Model loaded successfully: {:?}", model_data),
/// Err(error) => eprintln!("Error loading model: {:?}", error),
/// }
/// ```
pub fn load_model<P>(&mut self, path: P) -> Result<(), LoadError>
where
P: AsRef<Path>,
{
// Attempt to read the file
let file_content = fs::read_to_string(&path).map_err(LoadError::Io)?;
let model_data: GlobalConfig = toml::from_str(&file_content).unwrap(); //. .ok_or(LoadError::InvalidFormat);
self.config = Some(model_data);
Ok(())
}
}
#[cfg(test)]
mod tests {
use std::path::Path;
use crate::loader::SheetModel;
#[test]
fn test_creation() {
let modl = SheetModel::new();
assert!(modl.config.is_none())
}
#[test]
fn test_load() {
let mut modl = SheetModel::new();
assert!(modl.load_model(Path::new("data/cyberpunk.toml")).is_ok());
assert!(modl.config.is_some())
}
#[test]
fn test_bad_load() {
let mut modl = SheetModel::new();
assert!(modl.load_model(Path::new("wrong_file")).is_err())
}
}

8
src/main.rs Normal file
View File

@ -0,0 +1,8 @@
mod data_structure;
mod export;
mod generator;
mod loader;
fn main() {
println!("Hello, world!");
}