Skip to content

Commit

Permalink
encounter admin & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Apr 14, 2024
1 parent 23b3bb7 commit c9dc5e9
Show file tree
Hide file tree
Showing 31 changed files with 659 additions and 166 deletions.
34 changes: 30 additions & 4 deletions src/config/config.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rollyourown::config::{
hustlers::{HustlerConfig, HustlerImpl},
game::{GameConfig}, drugs::{DrugConfig}
game::{GameConfig}, drugs::{DrugConfig}, encounters::{EncounterConfig},
};


Expand All @@ -11,9 +11,9 @@ trait IConfig<T> {
fn get_config(self: @T) -> Config;
fn update_game_config(self: @T, game_config: GameConfig);
fn update_drug_config(self: @T, drug_config: DrugConfig);
fn update_encounter_config(self: @T, encounter_config: EncounterConfig);


// fn update_drug_config_meta(self: @T);
// ...
}

#[derive(Drop, Serde)]
Expand Down Expand Up @@ -52,7 +52,7 @@ mod config {
initialize_clothes_tiers_config, initialize_feet_tiers_config,
initialize_transport_tiers_config,
},
encounters::{initialize_encounter_config, EncounterConfig, Encounters},
encounters::{initialize_encounter_config,initialize_encounter_config_extra, EncounterConfig, Encounters},
},
packing::{
game_store_layout::{
Expand Down Expand Up @@ -104,6 +104,8 @@ mod config {

// encounters
initialize_encounter_config(world);
initialize_encounter_config_extra(world);

}

fn get_config(self: @ContractState) -> Config {
Expand Down Expand Up @@ -184,6 +186,30 @@ mod config {
set!(self.world(), (to_update));
}

fn update_encounter_config(self: @ContractState, encounter_config: EncounterConfig) {
self.assert_caller_is_owner();

let mut to_update = get!(self.world(), (encounter_config.id), (EncounterConfig));

to_update.encounter = encounter_config.encounter;

to_update.level = encounter_config.level;
to_update.health = encounter_config.health;
to_update.attack = encounter_config.attack;
to_update.defense = encounter_config.defense;
to_update.speed = encounter_config.speed;

to_update.rep_pay = encounter_config.rep_pay;
to_update.rep_run = encounter_config.rep_run;
to_update.rep_fight = encounter_config.rep_fight;

to_update.min_rep = encounter_config.min_rep;
to_update.max_rep = encounter_config.max_rep;

to_update.payout = encounter_config.payout;

set!(self.world(), (to_update));
}

}

Expand Down
149 changes: 126 additions & 23 deletions src/config/drugs.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Ludes,
drug_id: Drugs::Ludes.into(),
base: 18,
step: 1,
weight: 5,
base: 24,
step: 2,
weight: 10,
name: Bytes16Impl::from('Ludes')
}
);
Expand All @@ -143,9 +143,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Speed,
drug_id: Drugs::Speed.into(),
base: 85,
step: 6,
weight: 10,
base: 150,
step: 4,
weight: 14,
name: Bytes16Impl::from('Speed')
}
);
Expand All @@ -155,9 +155,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Weed,
drug_id: Drugs::Weed.into(),
base: 290,
step: 18,
weight: 15,
base: 402,
step: 8,
weight: 19,
name: Bytes16Impl::from('Weed')
}
);
Expand All @@ -167,9 +167,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Shrooms,
drug_id: Drugs::Shrooms.into(),
base: 980,
step: 54,
weight: 25,
base: 906,
step: 16,
weight: 27,
name: Bytes16Impl::from('Shrooms')
}
);
Expand All @@ -179,9 +179,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Acid,
drug_id: Drugs::Acid.into(),
base: 2900,
step: 111,
weight: 30,
base: 1914,
step: 32,
weight: 37,
name: Bytes16Impl::from('Acid')
}
);
Expand All @@ -191,9 +191,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Ketamine,
drug_id: Drugs::Ketamine.into(),
base: 6800,
step: 186,
weight: 45,
base: 3930,
step: 64,
weight: 52,
name: Bytes16Impl::from('Ketamine')
}
);
Expand All @@ -203,9 +203,9 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Heroin,
drug_id: Drugs::Heroin.into(),
base: 13500,
step: 231,
weight: 65,
base: 7962,
step: 128,
weight: 72,
name: Bytes16Impl::from('Heroin')
}
);
Expand All @@ -215,10 +215,113 @@ fn initialize_drug_config(world: IWorldDispatcher) {
DrugConfig {
drug: Drugs::Cocaine,
drug_id: Drugs::Cocaine.into(),
base: 19800,
step: 284,
base: 16026,
step: 256,
weight: 100,
name: Bytes16Impl::from('Cocaine')
}
);
}


//
//
//

// fn initialize_drug_config_v0(world: IWorldDispatcher) {
// set!(
// world,
// DrugConfig {
// drug: Drugs::Ludes,
// drug_id: Drugs::Ludes.into(),
// base: 18,
// step: 1,
// weight: 5,
// name: Bytes16Impl::from('Ludes')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Speed,
// drug_id: Drugs::Speed.into(),
// base: 85,
// step: 6,
// weight: 10,
// name: Bytes16Impl::from('Speed')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Weed,
// drug_id: Drugs::Weed.into(),
// base: 290,
// step: 18,
// weight: 15,
// name: Bytes16Impl::from('Weed')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Shrooms,
// drug_id: Drugs::Shrooms.into(),
// base: 980,
// step: 54,
// weight: 25,
// name: Bytes16Impl::from('Shrooms')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Acid,
// drug_id: Drugs::Acid.into(),
// base: 2900,
// step: 111,
// weight: 30,
// name: Bytes16Impl::from('Acid')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Ketamine,
// drug_id: Drugs::Ketamine.into(),
// base: 6800,
// step: 186,
// weight: 45,
// name: Bytes16Impl::from('Ketamine')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Heroin,
// drug_id: Drugs::Heroin.into(),
// base: 13500,
// step: 231,
// weight: 65,
// name: Bytes16Impl::from('Heroin')
// }
// );

// set!(
// world,
// DrugConfig {
// drug: Drugs::Cocaine,
// drug_id: Drugs::Cocaine.into(),
// base: 19800,
// step: 284,
// weight: 100,
// name: Bytes16Impl::from('Cocaine')
// }
// );
// }
Loading

0 comments on commit c9dc5e9

Please sign in to comment.