Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
48 changes: 7 additions & 41 deletions src/interfaces/IActions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ use dojo_starter::model::game_model::{GameType, Game};
use dojo_starter::model::game_player_model::{PlayerSymbol, GamePlayer};
use dojo_starter::model::player_model::Player;
use dojo_starter::model::property_model::{Property, TradeOffer, TradeOfferDetails};
use dojo_starter::model::utility_model::Utility;
use dojo_starter::model::rail_road_model::RailRoad;
use dojo_starter::model::community_chest_model::CommunityChest;
use dojo_starter::model::chance_model::Chance;
use dojo_starter::model::jail_model::Jail;
use dojo_starter::model::go_free_parking_model::Go;
use dojo_starter::model::tax_model::Tax;
use starknet::{ContractAddress};


Expand All @@ -35,13 +28,7 @@ pub trait IActions<T> {

// Board spaces retrieval
fn get_property(self: @T, id: u8, game_id: u256) -> Property;
fn get_utility(self: @T, id: u8, game_id: u256) -> Utility;
fn get_chance(self: @T, id: u8, game_id: u256) -> Chance;
fn get_jail(self: @T, id: u8, game_id: u256) -> Jail;
fn get_go(self: @T, id: u8, game_id: u256) -> Go;
fn get_community_chest(self: @T, id: u8, game_id: u256) -> CommunityChest;
fn get_railroad(self: @T, id: u8, game_id: u256) -> RailRoad;
fn get_tax(self: @T, id: u8, game_id: u256) -> Tax;

fn use_getout_of_jail_chance(ref self: T, game_id: u256) -> bool;
fn use_getout_of_jail_community_chest(ref self: T, game_id: u256) -> bool;

Expand All @@ -65,6 +52,7 @@ pub trait IActions<T> {

fn reject_trade(ref self: T, trade_id: u256, game_id: u256) -> bool;

fn leave_game(ref self: T, game_id: u256, transfer_to: ContractAddress);
fn counter_trade(
ref self: T,
game_id: u256,
Expand All @@ -82,21 +70,10 @@ pub trait IActions<T> {
fn roll_dice(ref self: T) -> (u8, u8);
fn move_player(ref self: T, game_id: u256, steps: u8) -> u8;
fn pay_jail_fine(ref self: T, game_id: u256) -> bool;
// fn handle_chance(ref self: T, game_id: u256, random_index: u32) -> @ByteArray;

// Handling landings on board
// fn draw_chance_card(ref self: T, game_id: u256) -> Chance;
// fn draw_community_chest_card(ref self: T, game_id: u256) -> CommunityChest;
// fn pay_tax(ref self: T, game_id: u256, tax_id: u8) -> bool;
// fn go_to_jail(ref self: T, game_id: u256) -> bool;

// Jail specific actions
// fn pay_jail_fee(ref self: T, game_id: u256) -> bool;
// fn use_jail_card(ref self: T, game_id: u256) -> bool;

// Property transactions
fn buy_property(ref self: T, property: Property) -> bool;
fn sell_property(ref self: T, property_id: u8, game_id: u256) -> bool;
fn mortgage_property(ref self: T, property: Property) -> bool;
fn unmortgage_property(ref self: T, property: Property) -> bool;
fn pay_rent(ref self: T, property: Property) -> bool;
Expand All @@ -112,18 +89,9 @@ pub trait IActions<T> {
fn process_community_chest_card(
ref self: T, game: Game, player: GamePlayer, card: ByteArray,
) -> (Game, GamePlayer);
// Trading system
// fn offer_trade(
// ref self: T,
// game_id: u256,
// to: ContractAddress,
// offered_property_ids: Array<u8>,
// requested_property_ids: Array<u8>,
// cash_offer: u256,
// cash_request: u256
// );
// fn accept_trade(ref self: T, game_id: u256, trade_id: u256) -> bool;
// fn decline_trade(ref self: T, game_id: u256, trade_id: u256) -> bool;

fn bankruptcy_check(ref self: T, player: GamePlayer, amount_owed: u256);
fn vote_to_kick_player(ref self: T, game_id: u256, target_player: ContractAddress);

// // Auctions
// fn start_auction(ref self: T, property_id: u8, game_id: u256);
Expand All @@ -135,8 +103,6 @@ pub trait IActions<T> {
ref self: T, from: GamePlayer, to: GamePlayer, amount: u256,
) -> Array<GamePlayer>;
fn mint(ref self: T, recepient: ContractAddress, game_id: u256, amount: u256);
// Bankruptcy & ending game
// fn declare_bankruptcy(ref self: T, game_id: u256) -> bool;
// fn check_winner(self: @T, game_id: u256) -> Option<ContractAddress>;
// fn end_game(ref self: T, game_id: u256) -> bool;


}
7 changes: 0 additions & 7 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ pub mod model {
pub mod game_model;
pub mod player_model;
pub mod property_model;
pub mod utility_model;
pub mod rail_road_model;
pub mod chance_model;
pub mod community_chest_model;
pub mod jail_model;
pub mod go_free_parking_model;
pub mod tax_model;
pub mod game_player_model;
}

Expand Down
1 change: 0 additions & 1 deletion src/model/bank_model.cairo

This file was deleted.

46 changes: 0 additions & 46 deletions src/model/chance_model.cairo

This file was deleted.

35 changes: 0 additions & 35 deletions src/model/community_chest_model.cairo

This file was deleted.

2 changes: 0 additions & 2 deletions src/model/game_model.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use starknet::{ContractAddress, contract_address_const};
use dojo_starter::model::game_player_model::{GamePlayer, PlayerSymbol, GamePlayerTrait};
// Keeps track of the state of the game

#[derive(Serde, Copy, Drop, Introspect, PartialEq)]
Expand Down Expand Up @@ -206,4 +205,3 @@ pub impl GameBalanceImpl of IGameBalance {
true
}
}

2 changes: 2 additions & 0 deletions src/model/game_player_model.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct GamePlayer {
pub is_bankrupt: bool,
pub is_active: bool,
pub jail_turns: u8,
pub strikes: u8,
}


Expand Down Expand Up @@ -80,6 +81,7 @@ impl GamePlayerImpl of GamePlayerTrait {
no_section7: 0,
no_section8: 0,
jail_turns: 0,
strikes: 0,
}
}

Expand Down
26 changes: 0 additions & 26 deletions src/model/go_free_parking_model.cairo

This file was deleted.

36 changes: 0 additions & 36 deletions src/model/jail_model.cairo

This file was deleted.

31 changes: 2 additions & 29 deletions src/model/property_model.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -130,39 +130,12 @@ pub trait PropertyTrait {
fn change_game_property_ownership(
ref self: Property, new_owner: ContractAddress, owner: ContractAddress,
) -> bool;
// fn property_transfer(
// initiator_property: Property, initiator: GamePlayer, receiver: GamePlayer,
// ) -> (GamePlayer, GamePlayer, Property);

}


impl PropertyImpl of PropertyTrait {
// fn property_transfer(
// mut initiator_property: Property, mut initiator: GamePlayer, mut receiver: GamePlayer,
// ) -> (GamePlayer, GamePlayer, Property) {
// assert(initiator_property.game_id == receiver.game_id, 'Not in the same Game');

// // Update the property owner
// initiator_property.owner = receiver.address;

// // Build a new properties array for initiator excluding the transferred property
// let mut new_properties = array![];
// let mut i = 0;
// while (i < initiator.properties_owned.len()) {
// let prop = initiator.properties_owned[i];
// if prop.property_id != initiator_property.property_id {
// new_properties.append(prop);
// }
// i += 1;
// };
// initiator.properties_owned = new_properties;

// // Add the property to receiver's properties
// receiver.properties_owned.append(initiator_property);

// (initiator, receiver, initiator_property)
// }


fn new(
id: u8,
game_id: u256,
Expand Down
Loading
Loading