Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move setWorld to init method #73

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
315 changes: 154 additions & 161 deletions src/systems/world_setup.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ use bytebeasts::{
},
};

#[dojo::interface]
trait IWorldSetup {
fn setWorld(ref world: IWorldDispatcher);
}

#[dojo::contract]
mod world_setup {
use super::IWorldSetup;
mod world {
use starknet::{ContractAddress, get_caller_address};
use bytebeasts::{
models::{
Expand All @@ -21,171 +15,170 @@ mod world_setup {
},
};

#[abi(embed_v0)]
impl WorldSetupImpl of IWorldSetup<ContractState> {
fn setWorld(ref world: IWorldDispatcher) {
// Set Beasts
set!(
world,
(Beast {
beast_id: 1,
beast_name: 'Firebeast',
beast_type: WorldElements::Draconic(()),
beast_description: 'A fiery beast.',
player_id: 1,
hp: 100,
current_hp: 100,
attack: 50,
defense: 40,
mt1: 1, // Fire Blast
mt2: 2, // Ember
mt3: 3, // Flame Wheel
mt4: 4, // Fire Punch
level: 5,
experience_to_next_level: 1000
})
);
fn dojo_init(
world: @IWorldDispatcher,
) {
// Set Beasts
set!(
world,
(Beast {
beast_id: 1,
beast_name: 'Firebeast',
beast_type: WorldElements::Draconic(()),
beast_description: 'A fiery beast.',
player_id: 1,
hp: 100,
current_hp: 100,
attack: 50,
defense: 40,
mt1: 1, // Fire Blast
mt2: 2, // Ember
mt3: 3, // Flame Wheel
mt4: 4, // Fire Punch
level: 5,
experience_to_next_level: 1000
})
);

set!(
world,
(Beast {
beast_id: 2,
beast_name: 'Aqua',
beast_type: WorldElements::Crystal(()),
beast_description: 'A water beast',
player_id: 2,
hp: 110,
current_hp: 110,
attack: 45,
defense: 50,
mt1: 5, // Water Gun
mt2: 6, // Bubble
mt3: 7, // Aqua Tail
mt4: 8, // Hydro Pump
level: 5,
experience_to_next_level: 1000
})
);
set!(
world,
(Beast {
beast_id: 2,
beast_name: 'Aqua',
beast_type: WorldElements::Crystal(()),
beast_description: 'A water beast',
player_id: 2,
hp: 110,
current_hp: 110,
attack: 45,
defense: 50,
mt1: 5, // Water Gun
mt2: 6, // Bubble
mt3: 7, // Aqua Tail
mt4: 8, // Hydro Pump
level: 5,
experience_to_next_level: 1000
})
);

// Set Trainers
set!(
world,
(Player {
player_id: 1,
player_name: 'Ash',
beast_1: 1, // Hellooo
beast_2: 0, // No beast assigned
beast_3: 0, // No beast assigned
beast_4: 0, // No beast assigned
potions: 2
})
);
// Set Trainers
set!(
world,
(Player {
player_id: 1,
player_name: 'Ash',
beast_1: 1, // Hellooo
beast_2: 0, // No beast assigned
beast_3: 0, // No beast assigned
beast_4: 0, // No beast assigned
potions: 2
})
);

set!(
world,
(Player {
player_id: 2,
player_name: 'Misty',
beast_1: 2, // Aqua
beast_2: 0, // No beast assigned
beast_3: 0, // No beast assigned
beast_4: 0, // No beast assigned
potions: 3
})
);
set!(
world,
(Player {
player_id: 2,
player_name: 'Misty',
beast_1: 2, // Aqua
beast_2: 0, // No beast assigned
beast_3: 0, // No beast assigned
beast_4: 0, // No beast assigned
potions: 3
})
);

// Set Potions
set!(world, (Potion { potion_id: 1, potion_name: 'Health Potion', potion_effect: 50 }));
set!(world, (Potion { potion_id: 2, potion_name: 'Super Potion', potion_effect: 100 }));
// Set Potions
set!(world, (Potion { potion_id: 1, potion_name: 'Health Potion', potion_effect: 50 }));
set!(world, (Potion { potion_id: 2, potion_name: 'Super Potion', potion_effect: 100 }));

// Set Mts
set!(
world,
(Mt {
mt_id: 1,
mt_name: 'Fire Blast',
mt_type: WorldElements::Draconic(()),
mt_power: 90,
mt_accuracy: 85
})
);
// Set Mts
set!(
world,
(Mt {
mt_id: 1,
mt_name: 'Fire Blast',
mt_type: WorldElements::Draconic(()),
mt_power: 90,
mt_accuracy: 85
})
);

set!(
world,
(Mt {
mt_id: 2,
mt_name: 'Ember',
mt_type: WorldElements::Crystal(()),
mt_power: 40,
mt_accuracy: 100
})
);
set!(
world,
(Mt {
mt_id: 2,
mt_name: 'Ember',
mt_type: WorldElements::Crystal(()),
mt_power: 40,
mt_accuracy: 100
})
);

set!(
world,
(Mt {
mt_id: 3,
mt_name: 'Flame Wheel',
mt_type: WorldElements::Draconic(()),
mt_power: 60,
mt_accuracy: 95
})
);
set!(
world,
(Mt {
mt_id: 3,
mt_name: 'Flame Wheel',
mt_type: WorldElements::Draconic(()),
mt_power: 60,
mt_accuracy: 95
})
);

set!(
world,
(Mt {
mt_id: 4,
mt_name: 'Fire Punch',
mt_type: WorldElements::Crystal(()),
mt_power: 75,
mt_accuracy: 100
})
);
set!(
world,
(Mt {
mt_id: 4,
mt_name: 'Fire Punch',
mt_type: WorldElements::Crystal(()),
mt_power: 75,
mt_accuracy: 100
})
);

set!(
world,
(Mt {
mt_id: 5,
mt_name: 'Water Gun',
mt_type: WorldElements::Crystal(()),
mt_power: 40,
mt_accuracy: 100
})
);
set!(
world,
(Mt {
mt_id: 5,
mt_name: 'Water Gun',
mt_type: WorldElements::Crystal(()),
mt_power: 40,
mt_accuracy: 100
})
);

set!(
world,
(Mt {
mt_id: 6,
mt_name: 'Bubble',
mt_type: WorldElements::Draconic(()),
mt_power: 20,
mt_accuracy: 100
})
);
set!(
world,
(Mt {
mt_id: 6,
mt_name: 'Bubble',
mt_type: WorldElements::Draconic(()),
mt_power: 20,
mt_accuracy: 100
})
);

set!(
world,
(Mt {
mt_id: 7,
mt_name: 'Aqua Tail',
mt_type: WorldElements::Crystal(()),
mt_power: 90,
mt_accuracy: 90
})
);
set!(
world,
(Mt {
mt_id: 7,
mt_name: 'Aqua Tail',
mt_type: WorldElements::Crystal(()),
mt_power: 90,
mt_accuracy: 90
})
);

set!(
world,
(Mt {
mt_id: 8,
mt_name: 'Hydro Pump',
mt_type: WorldElements::Crystal(()),
mt_power: 110,
mt_accuracy: 80
})
);
}
set!(
world,
(Mt {
mt_id: 8,
mt_name: 'Hydro Pump',
mt_type: WorldElements::Crystal(()),
mt_power: 110,
mt_accuracy: 80
})
);
}
}