--- /dev/null
+Test program for model tools.
+
+This program creates a fake model that can be used to test tools like:
+
+* `nitdoc`
+* `nitmetrics`
+* `nitx`
+* or others `modelbuilder`.
+
--- /dev/null
+Gaming group
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A game abstraction for RPG.
+module game
+
+import rpg
+
+# This is the interface you have to implement to use ure gaming platform.
+#
+# see http://our.platform.com
+interface Game
+
+ # Characters played by human players.
+ fun player_characters: List[Character] is abstract
+
+ # Characters players by computer.
+ fun computer_characters: List[Character] is abstract
+
+ # Start the game.
+ #
+ # You have to implement that method!
+ fun start_game is abstract
+
+ # Pause the game.
+ #
+ # You have to implement that method!
+ fun pause_game is abstract
+
+ # Stop the game.
+ #
+ # You have to implement that method!
+ fun stop_game is abstract
+end
+
--- /dev/null
+Fictive Crappy Platform.
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Declares base types allowed on the platform.
+module platform
+
+import end
+
+# Root of everything.
+class Object
+ # Used for comparisons.
+ type OTHER: nullable Object
+
+ # Is `other` equqls to `self`?
+ fun ==(other: OTHER): Bool is intern
+
+ # Is `other` different from `self`?
+ fun !=(other: OTHER): Bool do return not self == other
+end
+
+# Some services about Integers.
+class Int
+ fun -: Int is intern
+ fun +(i: Int): Int is intern
+ fun -(i: Int): Int is intern
+ fun *(i: Int): Int is intern
+ fun /(i: Int): Int is intern
+ fun >(i: Int): Bool is intern
+ fun to_f: Float is intern
+end
+
+# Some services about Floats.
+class Float
+ fun +(f: Float): Float is intern
+ fun -(f: Float): Float is intern
+ fun *(f: Float): Float is intern
+ fun /(f: Float): Float is intern
+ fun >(f: Float): Bool is intern
+end
+
+# Booleans, `true` or `false`.
+class Bool end
+
+# Strings (there is no chars...).
+class String end
+
+# List of things.
+class List[E] end
--- /dev/null
+Role Playing Game group
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Careers of the game.
+#
+# All characters can have a `Career`.
+# A character can also quit its current career and start a new one.
+#
+# Available careers:
+#
+# * `Warrior`
+# * `Magician`
+# * `Alcoholic`
+module careers
+
+import platform
+
+# A `Career` gives a characteristic bonus or malus to the character.
+abstract class Career
+ var strength_bonus: Int
+ var endurance_bonus: Int
+ var intelligence_bonus: Int
+
+ init do end
+end
+
+# Warriors are good for fighting.
+class Warrior
+ super Career
+
+ init do
+ self.strength_bonus = 10
+ self.endurance_bonus = 10
+ self.intelligence_bonus = 0
+ end
+end
+
+# Magicians know magic and how to use it.
+class Magician
+ super Career
+
+ init do
+ self.strength_bonus = -5
+ self.endurance_bonus = 0
+ self.intelligence_bonus = 20
+ end
+end
+
+# Alcoholics are good to nothing escept taking punches.
+class Alcoholic
+ super Career
+
+ init do
+ self.strength_bonus = -20
+ self.endurance_bonus = 20
+ self.intelligence_bonus = -40
+ end
+end
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Characters are playable entity in the world.
+module character
+
+import races
+import careers
+
+# Characters can be played by both the human or the machine.
+class Character
+
+ # The `Race` of the character.
+ var race: Race
+
+ # The current `Career` of the character.
+ # Returns `null` if character is unemployed.
+ var career: nullable Career writable = null
+
+ fun quit do
+ career = null
+ end
+
+ var name: String
+ var age: Int
+ var sex: Bool
+
+ # The actual strength of the character.
+ #
+ # Returns `race.base_strength + career.strength_bonus` or just `race.base_strength` is unemployed.
+ fun total_strengh: Int do
+ if career != null then return race.base_strength + career.strength_bonus
+ return race.base_strength
+ end
+
+ # The actual endurance of the character.
+ fun total_endurance: Int do
+ if career != null then return race.base_endurance + career.endurance_bonus
+ return race.base_endurance
+ end
+
+ # The acutal intelligence of the character.
+ fun total_intelligence: Int do
+ if career != null then return race.base_intelligence + career.intelligence_bonus
+ return race.base_intelligence
+ end
+
+ # Maximum health of the character.
+ #
+ # Based on `total endurance * 10`.
+ fun max_health: Int do return total_endurance * 10
+
+ # The current `health` of the character.
+ #
+ # Starts at `max_health`.
+ var health: Int = max_health
+end
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# COmbat interactions between characters.
+module combat
+
+import character
+
+# Something that can be used to attack someone and inflict damage.
+interface Weapon
+ # Damage per second inflicted by this weapon.
+ fun dps: Float is abstract
+end
+
+# Something that can be combatted, it can `attack` and `defend`.
+#
+# World items can also be `Combatable`.
+# `defend` method is then used to determines how the object react to an attack
+# Some magical items can even `attack`.
+interface Combatable
+ fun hit_points: Int is abstract
+
+ # A `Combatable` can attack a `target` that is also a `Combatable`.
+ #
+ # Attack the `target` using `wepaon` and returns the number of inflicted hit points.
+ fun attack(target: Combatable, weapon: Weapon): Int is abstract
+
+ # Like `attack` but cannot be defended.
+ fun direct_attack(target: Combatable, weapon: Weapon): Int is abstract
+
+ # `Combatable` can defend against attacks.
+ #
+ # Defends against a number of received hit points and return the number of pared hit points.
+ #
+ # @param hit: damage received.
+ fun defend(hit: Int): Int is abstract
+
+ # Is the character still have hit_points?
+ fun is_dead: Bool do return hit_points > 0
+end
+
+# Characters are now `Comabatable`
+redef class Character
+ super Combatable
+
+ # Use character `health` to determines hit_points.
+ redef fun hit_points do return health
+end
+
+# Dwarves can be used as weapons.
+redef class Dwarf
+ super Weapon
+
+ # Dwarf `dps` are based on the dwarf `base_endurance` (represents weight here)
+ redef fun dps do return base_endurance.to_f / 10.0
+end
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Races of the game.
+#
+# All characters belong to a `Race`.
+#
+# Available races:
+#
+# * `Human`
+# * `Dwarf`
+# * `Elf`
+module races
+
+import platform
+
+# Race determines basic characteristics and what the character will be able to do in life.
+#
+# These are base characteristics, they cannot be changed
+# but you can add new ones if needed using refinement.
+# Objects and spells cannot change those characteristics.
+abstract class Race
+
+ # Used to represents how strong the race is.
+ var base_strength: Int
+
+ # Used to represents how the race can absorb damage.
+ var base_endurance: Int
+
+ # Is this race smart?
+ var base_intelligence: Int
+
+ init do end
+end
+
+# Humans are able to do everithing.
+class Human
+ super Race
+
+ init do
+ self.base_strength = 50
+ self.base_endurance = 50
+ self.base_intelligence = 50
+ end
+end
+
+# Dwarves make strong warriors.
+class Dwarf
+ super Race
+
+ init do
+ self.base_strength = 60
+ self.base_endurance = 50
+ self.base_intelligence = 40
+ end
+end
+
+# Elves make good magicians.
+class Elf
+ super Race
+
+ init do
+ self.base_strength = 40
+ self.base_endurance = 40
+ self.base_intelligence = 70
+ end
+end
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A worlg RPG abstraction.
+module rpg
+
+import races
+import careers
+import character
+import combat
+
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A test program with a fake model to check model tools.
+module test_prog
+
+import rpg
+import game
+
+class Starter
+ fun start do end
+end
+
+var starter = new Starter
+starter.start
+