-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Prisoner Mini Skirt", | ||
"type": "armor", | ||
"value": 15, | ||
"description": "A tattered and uncomfortable mini skirt.", | ||
"visuals": { | ||
"glyph": "A", | ||
"color": [139, 69, 19] | ||
}, | ||
"onuse": { | ||
"type": "protection", | ||
"protection_value": 10 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "The Bible", | ||
"type": "book", | ||
"value": 10, | ||
"description": "A holy book filled with ancient wisdom.", | ||
"visuals": { | ||
"glyph": "B", | ||
"color": [255, 255, 0] | ||
}, | ||
"onuse": { | ||
"type": "spell", | ||
"spell_name": "Blessing", | ||
"effect": "Heals the user and provides protection." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Milk", | ||
"type": "drink", | ||
"value": 5, | ||
"description": "Fresh and creamy milk.", | ||
"visuals": { | ||
"glyph": "D", | ||
"color": [255, 255, 255] | ||
}, | ||
"onuse": { | ||
"type": "thirst", | ||
"thirst_quenching": 15 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Red Bean Paste", | ||
"type": "food", | ||
"value": 5, | ||
"description": "A sweet and nutritious red bean paste.", | ||
"visuals": { | ||
"glyph": "F", | ||
"color": [255, 0, 0] | ||
}, | ||
"onuse": { | ||
"type": "hunger", | ||
"hunger_restoration": 20 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Rusty Sword", | ||
"type": "melee", | ||
"value": 20, | ||
"description": "A worn and rusty sword, but it can still cut.", | ||
"visuals": { | ||
"glyph": "S", | ||
"color": [128, 128, 128] | ||
}, | ||
"onuse": { | ||
"type": "damage", | ||
"damage": 15 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "Wooden Bow", | ||
"type": "ranged", | ||
"value": 30, | ||
"description": "A simple wooden bow for firing arrows.", | ||
"visuals": { | ||
"glyph": "B", | ||
"color": [139, 69, 19] | ||
}, | ||
"onuse": { | ||
"type": "shoot", | ||
"ammo_type": "arrow", | ||
"damage": 20 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// item.rs | ||
|
||
use bracket_lib::prelude::*; | ||
use serde::Deserialize; | ||
use std::error::Error; | ||
use std::fs; | ||
use crate::entity::Entity; | ||
#[derive(Debug, Deserialize)] | ||
pub struct ItemData { | ||
pub name: String, | ||
pub value: i32, | ||
pub description: String, | ||
pub visuals: Visuals, | ||
pub onuse: Option<OnUse>, | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Visuals { | ||
pub glyph: char, | ||
pub color: (u8, u8, u8), | ||
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct OnUse { | ||
pub r#type: String, | ||
#[serde(default)] | ||
pub hunger_restoration: i32, | ||
#[serde(default)] | ||
pub thirst_quenching: i32, | ||
// Add other possible effects here | ||
} | ||
|
||
pub struct Item { | ||
pub entity: Entity, | ||
pub data: ItemData, | ||
} | ||
|
||
impl Item { | ||
pub fn new(x: i32, y: i32, filename: &str) -> Result<Self, Box<dyn Error>> { | ||
let contents = fs::read_to_string(filename)?; | ||
let data: ItemData = serde_json::from_str(&contents)?; | ||
let entity = Entity::new(x, y, data.visuals.glyph as FontCharType, data.visuals.color, BLACK); | ||
|
||
Ok(Item { entity, data }) | ||
} | ||
|
||
pub fn draw(&self, ctx: &mut BTerm) { | ||
self.entity.draw(ctx); | ||
} | ||
|
||
// Implement item-specific methods here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters