1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Characters are playable entity in the world.
21 # Characters can be played by both the human or the machine.
24 # The `Race` of the character.
27 # The current `Career` of the character.
28 # Returns `null` if character is unemployed.
29 var career
: nullable Career = null is writable
39 # The actual strength of the character.
41 # Returns `race.base_strength + career.strength_bonus` or just `race.base_strength` is unemployed.
42 fun total_strengh
: Int do
43 if career
!= null then return race
.base_strength
+ career
.strength_bonus
44 return race
.base_strength
47 # The actual endurance of the character.
48 fun total_endurance
: Int do
49 if career
!= null then return race
.base_endurance
+ career
.endurance_bonus
50 return race
.base_endurance
53 # The acutal intelligence of the character.
54 fun total_intelligence
: Int do
55 if career
!= null then return race
.base_intelligence
+ career
.intelligence_bonus
56 return race
.base_intelligence
59 # Maximum health of the character.
61 # Based on `total endurance * 10`.
62 fun max_health
: Int do return total_endurance
* 10
64 # The current `health` of the character.
66 # Starts at `max_health`.
67 var health
: Int = max_health