framework for magic - spells NYI
This commit is contained in:
parent
4118783597
commit
a299496857
2 changed files with 36 additions and 4 deletions
|
|
@ -1,5 +1,8 @@
|
|||
use super::{gamesystem::attr_bonus, gamesystem::get_attribute_rolls, Attributes, Pools, Renderable, RunState, State};
|
||||
use crate::{ai::NORMAL_SPEED, raws, Attribute, Energy, HasAncestry, HasClass, Pool, Skill, Skills, Telepath, BUC};
|
||||
use crate::{
|
||||
ai::NORMAL_SPEED, raws, Attribute, Energy, HasAncestry, HasClass, KnownSpell, KnownSpells, Pool, Skill, Skills,
|
||||
Telepath, BUC,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::prelude::*;
|
||||
|
|
@ -261,9 +264,17 @@ pub fn setup_player_class(ecs: &mut World, class: Class, ancestry: Ancestry) {
|
|||
{
|
||||
let mut classes = ecs.write_storage::<HasClass>();
|
||||
classes.insert(player, HasClass { name: class }).expect("Unable to insert class component");
|
||||
if class == Class::Wizard {
|
||||
let mut spells = ecs.write_storage::<KnownSpells>();
|
||||
spells
|
||||
.insert(
|
||||
player,
|
||||
KnownSpells { spells: vec![KnownSpell { display_name: "zap".to_string(), mana_cost: 1 }] },
|
||||
)
|
||||
.expect("Unable to insert known spells component");
|
||||
}
|
||||
let mut rng = ecs.write_resource::<RandomNumberGenerator>();
|
||||
let mut attributes = ecs.write_storage::<Attributes>();
|
||||
|
||||
let (str, dex, con, int, wis, cha) = get_attribute_rolls(&mut rng, class, ancestry);
|
||||
attributes
|
||||
.insert(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use super::{
|
||||
ai::CARRY_CAPACITY_PER_STRENGTH, camera, gamelog, gamesystem, hunger_system::get_hunger_colour,
|
||||
rex_assets::RexAssets, ArmourClassBonus, Attributes, Beatitude, Burden, Charges, Equipped, Hidden, HungerClock,
|
||||
HungerState, InBackpack, MagicItem, Map, MasterDungeonMap, Name, ObfuscatedName, Player, Point, Pools, Position,
|
||||
Prop, Renderable, RunState, Skill, Skills, State, Viewshed, BUC,
|
||||
HungerState, InBackpack, KnownSpells, MagicItem, Map, MasterDungeonMap, Name, ObfuscatedName, Player, Point, Pools,
|
||||
Position, Prop, Renderable, RunState, Skill, Skills, State, Viewshed, BUC,
|
||||
};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
|
@ -208,6 +208,27 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
|||
let (player_inventory, _inventory_ids) = get_player_inventory(&ecs);
|
||||
y = print_options(player_inventory, 72, y, ctx).0;
|
||||
|
||||
// Draw spells - if we have any -- NYI!
|
||||
if let Some(known_spells) = ecs.read_storage::<KnownSpells>().get(*player_entity) {
|
||||
y += 1;
|
||||
// Draw known spells
|
||||
ctx.print_color(72, y, RGB::named(BLACK), RGB::named(WHITE), "Known Spells");
|
||||
y += 1;
|
||||
let mut index = 1;
|
||||
for spell in known_spells.spells.iter() {
|
||||
ctx.print_color(72, y, RGB::named(YELLOW), RGB::named(BLACK), &format!("{}", index));
|
||||
ctx.print_color(
|
||||
74,
|
||||
y,
|
||||
RGB::named(CYAN),
|
||||
RGB::named(BLACK),
|
||||
&format!("{} ({})", "Force Bolt - NYI!", spell.mana_cost),
|
||||
);
|
||||
index += 1;
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw entities seen on screen
|
||||
let viewsheds = ecs.read_storage::<Viewshed>();
|
||||
let renderables = ecs.read_storage::<Renderable>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue