Skip to content

Commit

Permalink
Add Upgrade slots (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: Antony Saba <antony@sabatechconsulting.com>
  • Loading branch information
awsaba and Antony Saba authored Jun 22, 2024
1 parent 4f27fb0 commit f0d20de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl PilotRecord {
pub struct UpgradeRecord {
pub xws: String,
pub r#type: String,
pub slots: String,
pub name: String,
pub faction_restriction: String,
pub size_restriction: String,
Expand Down Expand Up @@ -191,7 +192,19 @@ impl UpgradeRecord {
.sides
.first()
.map(|s| format!("{:?}", s.r#type)) //FIXME
.unwrap_or("not found".to_owned())
.unwrap_or("unknown".to_owned())
.to_owned(),
slots: u
.sides
.first()
.map(|s| {
s.slots
.iter()
.map(|k| format!("{:?}", k).to_owned())
.collect::<Vec<String>>()
.join(",")
})
.unwrap_or("unknown".to_owned())
.to_owned(),
faction_restriction: format_restriction(
data,
Expand Down Expand Up @@ -601,13 +614,14 @@ fn add_upgrades_sheet(
)?;

upgrades.write(upgrade_row, 4, &record.faction_restriction)?;
upgrades.write(upgrade_row, 5, &record.ship_restriction)?;
upgrades.write(upgrade_row, 6, &record.size_restriction)?;
upgrades.write(upgrade_row, 7, &record.arc_restriction)?;
upgrades.write(upgrade_row, 8, &record.force_side_restriction)?;
upgrades.write(upgrade_row, 9, &record.keyword_restriction)?;

upgrades.write(upgrade_row, 10, &upgrade.xws)?;
upgrades.write(upgrade_row, 5, &record.slots)?;
upgrades.write(upgrade_row, 6, &record.ship_restriction)?;
upgrades.write(upgrade_row, 7, &record.size_restriction)?;
upgrades.write(upgrade_row, 8, &record.arc_restriction)?;
upgrades.write(upgrade_row, 9, &record.force_side_restriction)?;
upgrades.write(upgrade_row, 10, &record.keyword_restriction)?;

upgrades.write(upgrade_row, 11, &upgrade.xws)?;
upgrades.write(
upgrade_row,
11,
Expand Down Expand Up @@ -636,6 +650,7 @@ fn add_upgrades_sheet(
TableColumn::new()
.set_header("Singles")
.set_total_function(TableFunction::Sum),
TableColumn::new().set_header("Slots"),
TableColumn::new().set_header("Faction Restriction"),
TableColumn::new().set_header("Ship Restriction"),
TableColumn::new().set_header("Size Restriction"),
Expand Down
1 change: 1 addition & 0 deletions src/xwingdata2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl XwsId for Ship {
#[derive(Deserialize, Debug)]
pub struct Side {
pub r#type: SlotKind,
pub slots: Vec<SlotKind>,
}

pub enum Restriction {
Expand Down

0 comments on commit f0d20de

Please sign in to comment.