Inheritence
Author |
Message |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Sat Dec 03, 2011 12:56 pm Post subject: Inheritence |
|
|
Basically I try and run my code, and it says "Circular dependency of unit 'Character'" (Character being one of my classes).
I have no idea what this error means, and I have checked over both my Character class and my Me class (Me inherits Character) for any sort of errors but cant find any to my knowledge.
Can someone please explain what this error means? thanks.
Turing: |
unit
class Character
import Item, Weapon, Room, Stuff
export SetWeapon, Move, SetPosition, x, y, t, weapon
var x, y, t : real := 0
var health, maxhealth : real := 70
var weapon : ^Weapon
var room : ^Room
proc SetWeapon (w : ^Weapon)
weapon := w
end SetWeapon
end Character
|
Turing: |
unit
class Me
inherit Character
import Item, Weapon %, Armor, Consumable
export NewMe, SetStats, SkillUp, bag
var name : string := ""
var level : int := 1
var intelligence, strength, agility : real := 1
var mana, maxmana : real := 50
var healthregain, manaregain : real := 0.5
var movementspeed : real := 2
var cooldownreduction : real := 1
var attackpower, spellpower : int := 0
var bag : array 1 .. 40 of ^Item
var armor : ^Item
proc NewMe (name : string)
for a : 1 .. 40
bag (a) := nil
end for
end NewMe
proc SetStats
maxhealth := 70 + strength * 20
healthregain := 0.5 + 0.2 * strength
maxmana := 50 + intelligence * 22
manaregain := 0.5 + 0.22 * intelligence
movementspeed := 2 + 0.015 * agility
cooldownreduction := agility ** (-0.5)
end SetStats
proc SkillUp (skill : string)
case skill of
label "str" :
strength += 1
label "agi" :
agility += 1
label "int" :
intelligence += 1
end case
SetStats
end SkillUp
end Me
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Sat Dec 03, 2011 2:41 pm Post subject: RE:Inheritence |
|
|
Does item, weapon, room or stuff import or inherit either one of those? |
|
|
|
|
![](images/spacer.gif) |
smool
![](http://compsci.ca/v3/uploads/user_avatars/19584221104f5399411b2b3.jpg)
|
Posted: Tue Dec 06, 2011 6:33 pm Post subject: RE:Inheritence |
|
|
ahh. yes, thx room imports character... thanks again ![Smile Smile](images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
mirhagk
|
Posted: Tue Dec 06, 2011 7:28 pm Post subject: RE:Inheritence |
|
|
No problem, the simplest problems cause the most pain. |
|
|
|
|
![](images/spacer.gif) |
|
|