
-----------------------------------
smool
Sat Dec 03, 2011 12:56 pm

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.


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




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


-----------------------------------
mirhagk
Sat Dec 03, 2011 2:41 pm

RE:Inheritence
-----------------------------------
Does item, weapon, room or stuff import or inherit either one of those?

-----------------------------------
smool
Tue Dec 06, 2011 6:33 pm

RE:Inheritence
-----------------------------------
ahh. yes, thx :) room imports character... thanks again :)

-----------------------------------
mirhagk
Tue Dec 06, 2011 7:28 pm

RE:Inheritence
-----------------------------------
No problem, the simplest problems cause the most pain.
