Skip to content

Commit

Permalink
common interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
zinoviy23 committed Mar 9, 2019
1 parent 24222dd commit e65d9bd
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.badgersOfKotlinForest.kotlinForest.actors

/**
* Interface for actors
*/
interface Actor {
/**
* Interacts with other actor
*/
fun interact(other: Actor)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.badgersOfKotlinForest.kotlinForest.actors

import io.github.badgersOfKotlinForest.kotlinForest.map.MapCellIndex
import io.github.badgersOfKotlinForest.kotlinForest.map.MapField

/**
* Actor, which can move
*/
interface MoveableActor : Actor {
/**
* Duration of actor movement
*/
val movementPeriod: Int

/**
* Moves the actor
*/
fun move(map: MapField, pos: MapCellIndex)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.badgersOfKotlinForest.kotlinForest.animals

import io.github.badgersOfKotlinForest.kotlinForest.actors.MoveableActor

/**
* Representation for animal
*/
interface Animal : MoveableActor {

/**
* Animal dies
*/
fun die()

/**
* Animal eats smth
*/
fun eat(food: Food)

/**
* Animal breeds with optional other Animal and creates new Animals
*/
fun breed(other: Animal?): List<Animal>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.badgersOfKotlinForest.kotlinForest.animals

import io.github.badgersOfKotlinForest.kotlinForest.actors.Actor

/**
* Representation for food
*/
interface Food : Actor {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.badgersOfKotlinForest.kotlinForest.map


typealias MapField = Array<Array<Array<MapItem>>>

/**
* Coordinates representation
*/
data class MapCellIndex(val x: Int, val y: Int, val z: Int)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.badgersOfKotlinForest.kotlinForest.map

import io.github.badgersOfKotlinForest.kotlinForest.actors.Actor

/**
* Cell of map
*/
class MapItem(val actors: MutableList<Actor>) {
constructor(): this(mutableListOf())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.badgersOfKotlinForest.kotlinForest.tree

/**
* Tree representation
*/
interface Tree {
val elements : List<TreeElement>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.badgersOfKotlinForest.kotlinForest.tree

import io.github.badgersOfKotlinForest.kotlinForest.actors.Actor

/**
* Element of tree
*/
interface TreeElement : Actor {
/**
* Is this dwelling of someone?
*/
val isDwelling: Boolean

/**
* Type of this tree element
*/
val type: TreeElementType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.badgersOfKotlinForest.kotlinForest.tree

/**
* Type of tree element
*/
enum class TreeElementType {
CROWN,
TRUNK,
ROOT
}

0 comments on commit e65d9bd

Please sign in to comment.