generated from tipragot/rust
This commit is contained in:
parent
28dffe4ce9
commit
1f4a813481
|
@ -2,56 +2,72 @@
|
||||||
|
|
||||||
use crate::map::Tile;
|
use crate::map::Tile;
|
||||||
|
|
||||||
|
/// A number of action points. This is decreased when you do an action.
|
||||||
|
pub struct ActionPoint(pub u32);
|
||||||
|
|
||||||
|
/// The action that you can do with a tile.
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
/// Build something on the tile.
|
||||||
Build(u32),
|
Build(u32),
|
||||||
|
|
||||||
|
/// Destroy something on the tile.
|
||||||
Destroy(u32),
|
Destroy(u32),
|
||||||
|
|
||||||
|
/// Recolt something on the tile.
|
||||||
Recolt(u32),
|
Recolt(u32),
|
||||||
|
|
||||||
|
/// Upgrade the tile.
|
||||||
Upgrade(u32),
|
Upgrade(u32),
|
||||||
|
|
||||||
|
/// Manage the villages.
|
||||||
VillageManagement,
|
VillageManagement,
|
||||||
|
|
||||||
|
/// Manage the troops.
|
||||||
TroopManagement,
|
TroopManagement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tile {
|
impl Tile {
|
||||||
pub fn get_action(&self, index_of_tile: u8) -> Vec<Action> {
|
/// Get the actions that you can do with the tile.
|
||||||
match *self {
|
pub fn get_action(&self, index_of_tile: u32) -> Vec<Action> {
|
||||||
Self::Breeding => [
|
let mut actions = vec![];
|
||||||
Action::Destroy(index_of_tile),
|
|
||||||
Action::Upgrade(index_of_tile),
|
if let Self::Breeding
|
||||||
],
|
| Self::Casern
|
||||||
Self::Casern => [
|
| Self::Castle
|
||||||
Action::Destroy(index_of_tile),
|
| Self::Mine
|
||||||
Action::Upgrade(index_of_tile),
|
| Self::Outpost
|
||||||
Action::TroopManagement,
|
| Self::Sawmill
|
||||||
],
|
| Self::Tower = *self
|
||||||
Self::Castle => [
|
{
|
||||||
Action::Upgrade(index_of_tile),
|
actions.push(Action::Upgrade(index_of_tile));
|
||||||
Action::VillageManagement,
|
|
||||||
],
|
|
||||||
Self::Hill => [
|
|
||||||
Action::Recolt(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Grass => [
|
|
||||||
Action::Build(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Forest => [
|
|
||||||
Action::Recolt(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Mine => [
|
|
||||||
Action::Destroy(index_of_tile),
|
|
||||||
Action::Upgrade(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Outpost => [
|
|
||||||
Action::Destroy(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Sawmill => [
|
|
||||||
Action::Destroy(index_of_tile),
|
|
||||||
Action::Recolt(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Tower => [
|
|
||||||
Action::Destroy(index_of_tile),
|
|
||||||
Action::Upgrade(index_of_tile),
|
|
||||||
],
|
|
||||||
Self::Wall => [],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Self::Breeding | Self::Casern | Self::Mine | Self::Outpost | Self::Sawmill = *self {
|
||||||
|
actions.push(Action::Destroy(index_of_tile));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Self::Breeding | Self::Casern = *self {
|
||||||
|
actions.push(Action::TroopManagement);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Self::Breeding | Self::Hill = *self {
|
||||||
|
actions.push(Action::Recolt(index_of_tile));
|
||||||
|
}
|
||||||
|
|
||||||
|
actions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Action {
|
||||||
|
/// Get the cost of an action.
|
||||||
|
pub fn point_cost(&self) -> ActionPoint {
|
||||||
|
ActionPoint(match *self {
|
||||||
|
Action::Build(_) => 50,
|
||||||
|
Action::Destroy(_) => 10,
|
||||||
|
Action::Recolt(_) => 10,
|
||||||
|
Action::Upgrade(_) => 25,
|
||||||
|
Action::VillageManagement => 0,
|
||||||
|
Action::TroopManagement => 0,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue