Update cards.

This commit is contained in:
yukirij 2024-09-25 18:02:17 -07:00
parent 943f2b1159
commit 371fed8b2b
11 changed files with 894 additions and 218 deletions

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ impl Format {
pub enum Category {
Equipment,
Field,
Item,
Ammunition,
Structure,
Unit,
Upgrade,
@ -69,7 +69,7 @@ impl Card {
Self {
format,
category:Category::Item,
category:Category::Ammunition,
name:String::new(),
payload:0,
@ -204,7 +204,7 @@ impl Card {
}.to_string() + " " + match &self.category {
Category::Equipment => "equipment",
Category::Field => "field",
Category::Item => "item",
Category::Ammunition => "item",
Category::Structure => "structure",
Category::Unit => "unit",
Category::Upgrade => "upgrade",

View File

@ -0,0 +1,6 @@
#[derive(Clone)]
pub struct AmmoUse {
pub index:Option<usize>,
pub hits:u8,
pub salvo:u8,
}

View File

@ -2,6 +2,6 @@
pub struct Damage {
pub damage:i8,
pub penetration:i8,
pub hits:i8,
pub impact:i8,
pub relative:bool,
}

View File

@ -3,6 +3,7 @@ pub struct Hardpoint {
pub class:usize,
pub subclass:Option<usize>,
pub size:u8,
pub relative:Option<char>,
pub internal:bool,
}

View File

@ -6,6 +6,7 @@ mod field; use field::Field;
mod damage; use damage::Damage;
mod range; use range::Range;
mod ammo; use ammo::Ammo;
mod ammo_use; use ammo_use::AmmoUse;
mod hardpoint; use hardpoint::{Slots, Hardpoint};
mod health; use health::Health;
mod criticals; use criticals::Criticals;
@ -20,6 +21,7 @@ pub enum ComponentData {
Damage(Damage),
Range(Range),
Ammo(Ammo),
AmmoUse(AmmoUse),
Armor(Health),
Health(Health),
@ -77,10 +79,10 @@ impl Component {
}))
}
pub fn damage(damage:i8, penetration:i8, hits:i8, relative:bool) -> Self
pub fn damage(damage:i8, penetration:i8, impact:i8, relative:bool) -> Self
{
Self::new().with(ComponentData::Damage(Damage {
damage, penetration, hits, relative,
damage, penetration, impact, relative,
}))
}
@ -98,6 +100,13 @@ impl Component {
}))
}
pub fn ammo_use(index:Option<usize>, hits:u8, salvo:u8) -> Self
{
Self::new().with(ComponentData::AmmoUse(AmmoUse {
index, hits, salvo,
}))
}
pub fn mount() -> Self
{
Self::new().with(ComponentData::Mount(Slots {
@ -164,14 +173,14 @@ impl Component {
}
pub fn hardpoint(mut self, class:usize, subclass:Option<usize>, size:u8, internal:bool) -> Self
pub fn hardpoint(mut self, class:usize, subclass:Option<usize>, size:u8, relative:Option<char>, internal:bool) -> Self
{
match &mut self.data {
ComponentData::Mount(data) => {
data.hardpoints.push(Hardpoint { class, subclass, size, internal });
data.hardpoints.push(Hardpoint { class, subclass, size, relative, internal });
}
ComponentData::Slots(data) => {
data.hardpoints.push(Hardpoint { class, subclass, size, internal });
data.hardpoints.push(Hardpoint { class, subclass, size, relative, internal });
}
_ => { }
}
@ -235,6 +244,16 @@ impl Component {
result.push((self.x, self.y, 0));
}
ComponentData::AmmoUse(_) => {
for y in 0..2 {
for x in 0..5 {
result.push((self.x + x, self.y + y, 0xFF));
}
}
result.push((self.x, self.y, 0));
result.push((self.x, self.y + 1, 1));
}
ComponentData::Health(data) | ComponentData::Armor(data) => {
let basis = if data.class.is_some() { 2 } else { 1 };
for x in 0..basis+(data.entries.len() as u8 * self.w) {
@ -313,12 +332,12 @@ impl Component {
ComponentData::Damage(data) => {
match row {
0 => {
output += &format!("<th colspan=\"{}\">Dmg</th><th colspan=\"{}\">Pen</th><th colspan=\"{}\">Hit</th>", self.w, self.w, self.w);
output += &format!("<th colspan=\"{}\">Dmg</th><th colspan=\"{}\">Pen</th><th colspan=\"{}\">Imp</th>", self.w, self.w, self.w);
}
1 => {
output += &format!("<td colspan=\"{}\" rowspan=\"{}\">{}</td>", self.w, self.h, util::print_value(data.damage, false));
output += &format!("<td colspan=\"{}\" rowspan=\"{}\">{}</td>", self.w, self.h, util::print_value(data.penetration, false));
output += &format!("<td colspan=\"{}\" rowspan=\"{}\">{}</td>", self.w, self.h, util::print_value(data.hits, false));
output += &format!("<td colspan=\"{}\" rowspan=\"{}\">{}</td>", self.w, self.h, util::print_value(data.impact, false));
}
_ => { }
}
@ -369,6 +388,24 @@ impl Component {
}
}
ComponentData::AmmoUse(data) => {
match row {
0 => {
output += "<th colspan=\"2\">Ammo</th>";
output += "<th>Hit</th>";
output += "<th></th>";
output += "<th>Salvo</th>";
}
1 => {
output += &format!("<td colspan=\"2\">{}</td>", util::print_ammo_class(data.index));
output += &format!("<td>{}</td>", util::print_value(data.hits as i8, false));
output += "<td></td>";
output += &format!("<td>{}</td>", util::print_value(data.salvo as i8, false));
}
_ => { }
}
}
ComponentData::Mount(data) => {
match row {
0 => {
@ -381,7 +418,13 @@ impl Component {
if let Some(subclass) = hp.subclass {
inner += &format!("<div class=\"subclass\">{}</div>", HARDPOINT_SUBCODE[subclass].name);
}
inner += &format!("<div class=\"class\">{}</div>", hp.size);
inner += &format!("<div class=\"class\">{}</div>", if let Some(rel) = hp.relative {
if hp.size > 0 {
format!("{}+{}", rel, hp.size)
} else {
format!("{}", rel)
}
} else { format!("{}", hp.size) });
inner += "</div>";
}
@ -404,7 +447,13 @@ impl Component {
if let Some(subclass) = hp.subclass {
inner += &format!("<div class=\"subclass\">{}</div>", HARDPOINT_SUBCODE[subclass].name);
}
inner += &format!("<div class=\"class\">{}</div>", hp.size);
inner += &format!("<div class=\"class\">{}</div>", if let Some(rel) = hp.relative {
if hp.size > 0 {
format!("{}+{}", rel, hp.size)
} else {
format!("{}", rel)
}
} else { format!("{}", hp.size) });
inner += "</div>";
}

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,14 @@ pub const AMMO_CLASS :&[AmmoClass] = &[
AmmoClass {
name:"AM-12",
},
AmmoClass {
name:"AC-20",
},
AmmoClass {
name:"SH-90",
},
];
pub const AC_HG9 :usize = 0;
@ -29,3 +37,5 @@ pub const AC_BS2 :usize = 1;
pub const AC_AR6 :usize = 2;
pub const AC_AR8 :usize = 3;
pub const AC_AM12 :usize = 4;
pub const AC_AC20 :usize = 5;
pub const AC_SH90 :usize = 6;

View File

@ -3,6 +3,10 @@ pub struct Code {
}
pub const HARDPOINT_CODE :&[Code] = &[
Code {
name:"",
},
Code {
name:"IRS",
},
@ -45,12 +49,13 @@ pub const HARDPOINT_SUBCODE :&[Code] = &[
pub const HP_MOUNT :usize = 0;
pub const HP_SLOTS :usize = 0;
pub const HP_IRS :usize = 0;
pub const HP_GM :usize = 1;
pub const HP_TR :usize = 2;
pub const HP_VST :usize = 3;
pub const HP_BPK :usize = 4;
pub const HP_DI :usize = 5;
pub const HP_ANY :usize = 0;
pub const HP_IRS :usize = 1;
pub const HP_GM :usize = 2;
pub const HP_TR :usize = 3;
pub const HP_VST :usize = 4;
pub const HP_BPK :usize = 5;
pub const HP_DI :usize = 6;
pub const HPS_OP :usize = 0;
pub const HPS_UN :usize = 1;

View File

@ -1,61 +1,61 @@
pub struct Label {
pub name:&'static str,
pub detail:&'static str,
}
pub const LABELS :&[Label] = &[
Label {
name:"Airburst",
},
Label {
name:"ATOL",
},
Label {
name:"Auto",
detail:"May take actions without a unit.",
},
Label {
name:"Blowout",
},
Label {
name:"Coaxial",
detail:"Multiple weapons may be fired per attack at +1 TN per additional.",
},
Label {
name:"Concealed",
detail:"Card may be hidden from view.",
},
Label {
name:"Crew",
detail:"Attacks must be made by an Infantry unit.",
},
Label {
name:"Explosive",
detail:"Each point of damage is applied as a separate hit.",
},
Label {
name:"Infantry",
detail:"Asset may only be used by Infantry units.",
},
Label {
name:"Multifire",
detail:"Multiple attacks may be made against a target at +2 TN.",
},
Label {
name:"Resilient",
detail:"Unit takes at most 1 damage per hit.",
},
Label {
name:"Vehicle",
detail:"Asset may not be used by Infantry units.",
},
];
pub const LB_AUTO :usize = 0;
pub const LB_COAXIAL :usize = 1;
pub const LB_CONCEALED :usize = 2;
pub const LB_CREW :usize = 3;
pub const LB_EXPLOSIVE :usize = 4;
pub const LB_INFANTRY :usize = 5;
pub const LB_MULTIFIRE :usize = 6;
pub const LB_RESILIENT :usize = 7;
pub const LB_VEHICLE :usize = 8;
pub const LB_AIRBURST :usize = 0;
pub const LB_ATOL :usize = 1;
pub const LB_AUTO :usize = 2;
pub const LB_BLOWOUT :usize = 3;
pub const LB_COAXIAL :usize = 4;
pub const LB_CONCEALED :usize = 5;
pub const LB_CREW :usize = 6;
pub const LB_EXPLOSIVE :usize = 7;
pub const LB_INFANTRY :usize = 8;
pub const LB_RESILIENT :usize = 9;
pub const LB_VEHICLE :usize = 10;

View File

@ -41,7 +41,7 @@ pub fn print_bubbles(value:u8) -> String
let mut value = value;
let row_size = if value > 5 {
value / ((value / 5) + (value % 10 > 0) as u8)
value / ((value / 5) + (value % 5 > 0) as u8)
} else {
value
};