Another Question

Blacktooth bt at whitestar.soark.net
Tue Dec 21 10:46:10 UTC 1999


------=_NextPart_000_5b60e87e_7ad6adfe$51cab010
Content-Type: TEXT/PLAIN; FORMAT=flowed
Content-ID: <Pine.GLC.3.96.991221053635.23434G at whitestar0.b5>



On the Class side of this attached object in the Initialize-Release
Category is a method called 'buildSkillReferences'.

The first part of it works fine ( two nested loops that define tempRefs).

The second part does not behave anything like what I want/expected.

At best, I got 'skillReferences' to be exactly the same as 'tempRefs',
but it should be an expanded version (take the initial parts of 'tempRefs'
and expand them down).


It is driving me nuts. 

Is 'tempDeps do:' not changing after the 'remove:' or 'addAll:' in the
'whileTrue: []' block?


If you can solve this, I'll give ya a big fat sloopy smooch.


BT

------=_NextPart_000_5b60e87e_7ad6adfe$51cab010
Content-Type: TEXT/PLAIN; NAME="MactoSkill.st"; FORMAT=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-ID: <Pine.GLC.3.96.991221053635.23434H at whitestar0.b5>
Content-Description: 


'From Squeak2.6 of 11 October 1999 [latest update: #1559] on 21 December=20=
=0D
1999 at 5:35:02 am'!=0D
Object subclass: #MactoSkill=0D
=09instanceVariableNames:=20=0D
'baseValue totalValue myPlayer myName baseDependants skillDependants=20=0D
'=0D
=09classVariableNames: 'AttReferences MaxBaseValue MinBaseValue=20=0D
SkillReferences Skills '=0D
=09poolDictionaries: ''=0D
=09category:=20=0D
'MyJunk'!=0D
=0D
!MactoSkill methodsFor: 'utilities' stamp: 'rws 12/20/1999=20=0D
04:14'!=0D
calcTotal=0D
=0D
| total tick att mlt skl |=0D
=0D
     tick :=3D 1.=0D
     total :=3D=20=0D
0.=0D
=0D
     1 to: ((baseDependants size) // 2) do: [ :i |=0D
          att :=3D=20=0D
(baseDependants at: tick).=0D
          mlt :=3D (baseDependants at: tick + 1).=0D
 =20=0D
         total :=3D total + (((myPlayer getAtt: att) currentValue) * mlt).=
=0D
   =20=0D
       tick :=3D tick + 2. ].=0D
=0D
     tick :=3D 1.=0D
=0D
     1 to: ((skillDependants=20=0D
size) // 2) do: [ :i |=0D
          skl :=3D (skillDependants at: tick).=0D
        =20=0D
  mlt :=3D (skillDependants at: tick + 1).=0D
          total :=3D total +=20=0D
(((myPlayer getSkill: skl) baseValue) * mlt).=0D
          tick :=3D tick + 2.=20=0D
].=0D
=0D
     total :=3D total // 2.=0D
     total :=3D total + (baseValue * 5).=0D
=0D
^ self=20=0D
totalValue: total.! !=0D
=0D
!MactoSkill methodsFor: 'utilities' stamp: 'rws=20=0D
12/21/1999 01:11'!=0D
getSkill: aSymbol=0D
=0D
     (Skills includesKey: aSymbol)=0D
   =20=0D
       ifTrue: [ ^ (Skills at: aSymbol) ]=0D
          ifFalse: [ ^ false ].=0D
!=20=0D
!=0D
=0D
!MactoSkill methodsFor: 'utilities' stamp: 'rws 12/16/1999=20=0D
04:20'!=0D
initialize=0D
=0D
baseValue :=3D 0.! !=0D
=0D
!MactoSkill methodsFor: 'utilities'=20=0D
stamp: 'rws 12/20/1999 04:10'!=0D
lowerBy: anInteger=0D
=0D
     ((baseValue -=20=0D
anInteger) <=3D (MactoSkill MinBaseValue))=0D
          ifTrue: [ self baseValue:=20=0D
(MactoSkill MinBaseValue).=0D
                     ^ baseValue. ]=0D
         =20=0D
ifFalse: [ self baseValue: (baseValue - anInteger).=0D
                     ^=20=0D
baseValue. ].! !=0D
=0D
!MactoSkill methodsFor: 'utilities' stamp: 'rws 12/20/1999=20=0D
04:04'!=0D
raiseBy: anInteger=0D
=0D
     ((baseValue + anInteger) >=3D (MactoSkill=20=0D
MaxBaseValue))=0D
          ifTrue: [ self baseValue: (MactoSkill=20=0D
MaxBaseValue).=0D
                     ^ baseValue. ]=0D
          ifFalse: [ self=20=0D
baseValue: (baseValue + anInteger).=0D
                     ^ baseValue. ].!=20=0D
!=0D
=0D
!MactoSkill methodsFor: 'utilities' stamp: 'rws 12/20/1999=20=0D
03:47'!=0D
refreshSubs=0D
=0D
| subs |=0D
=0D
     subs :=3D (MactoSkill getSkillReferences:=20=0D
myName).=0D
=0D
     subs do: [ :sub | sub calcTotal ].=0D
=0D
^ nil! !=0D
=0D
!MactoSkill=20=0D
methodsFor: 'utilities' stamp: 'rws 12/21/1999 01:12'!=0D
setDependants=0D
=0D
|=20=0D
skill |=0D
=0D
     skill :=3D self getSkill: myName.=0D
=0D
     self baseDependants:=20=0D
(skill at: 1).=0D
     self skillDependants: (skill at: 2).! !=0D
=0D
=0D
!MactoSkill=20=0D
methodsFor: 'access' stamp: 'rws 12/16/1999 01:01'!=0D
baseDependants=0D
=0D
^=20=0D
baseDependants! !=0D
=0D
!MactoSkill methodsFor: 'access' stamp: 'rws 12/16/1999=20=0D
01:02'!=0D
baseDependants: aList=0D
=0D
^ baseDependants :=3D aList! !=0D
=0D
!MactoSkill=20=0D
methodsFor: 'access' stamp: 'rws 12/16/1999 00:56'!=0D
baseValue=0D
=0D
^ baseValue!=20=0D
!=0D
=0D
!MactoSkill methodsFor: 'access' stamp: 'rws 12/16/1999=20=0D
00:58'!=0D
baseValue: anInteger=0D
=0D
^ baseValue :=3D anInteger! !=0D
=0D
!MactoSkill=20=0D
methodsFor: 'access' stamp: 'rws 12/16/1999 01:00'!=0D
myName=0D
=0D
^ myName!=20=0D
!=0D
=0D
!MactoSkill methodsFor: 'access' stamp: 'rws 12/16/1999 01:00'!=0D
myName:=20=0D
aString=0D
=0D
^ myName :=3D aString! !=0D
=0D
!MactoSkill methodsFor: 'access' stamp:=20=0D
'rws 12/16/1999 00:59'!=0D
myPlayer=0D
=0D
^ myPlayer! !=0D
=0D
!MactoSkill methodsFor:=20=0D
'access' stamp: 'rws 12/16/1999 01:00'!=0D
myPlayer: aPlayer=0D
=0D
^ myPlayer :=3D=20=0D
aPlayer! !=0D
=0D
!MactoSkill methodsFor: 'access' stamp: 'rws 12/16/1999=20=0D
01:02'!=0D
skillDependants=0D
=0D
^ skillDependants! !=0D
=0D
!MactoSkill methodsFor:=20=0D
'access' stamp: 'rws 12/16/1999 01:02'!=0D
skillDependants: aList=0D
=0D
^=20=0D
skillDependants :=3D aList! !=0D
=0D
!MactoSkill methodsFor: 'access' stamp: 'rws=20=0D
12/16/1999 00:57'!=0D
totalValue=0D
=0D
^ totalValue! !=0D
=0D
!MactoSkill methodsFor:=20=0D
'access' stamp: 'rws 12/16/1999 00:57'!=0D
totalValue: anInteger=0D
=0D
^ totalValue=20=0D
:=3D anInteger! !=0D
=0D
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --=20=0D
"!=0D
=0D
MactoSkill class=0D
=09instanceVariableNames: ''!=0D
=0D
!MactoSkill class=20=0D
methodsFor: 'instance creation' stamp: 'rws 12/17/1999 04:55'!=0D
new:=20=0D
aSymbol=0D
=0D
| skl temp |    =20=0D
=0D
     skl :=3D self new.=0D
     temp :=3D (skl=20=0D
getSkill: aSymbol).=0D
=0D
     skl myName: (temp at: 1);=0D
         baseDependants:=20=0D
(temp at: 2);=0D
         skillDependants: (temp at: 3);=0D
         baseValue:=20=0D
0.=0D
=0D
^ skl! !=0D
=0D
=0D
!MactoSkill class methodsFor: 'accessing' stamp: 'rws=20=0D
12/20/1999 03:26'!=0D
attReferences=0D
=0D
^ AttReferences! !=0D
=0D
!MactoSkill class=20=0D
methodsFor: 'accessing' stamp: 'rws 12/20/1999 05:26'!=0D
attReferences:=20=0D
aThing=0D
=0D
^ AttReferences :=3D aThing! !=0D
=0D
!MactoSkill class methodsFor:=20=0D
'accessing' stamp: 'rws 12/20/1999 03:26'!=0D
skillReferences=0D
=0D
^=20=0D
SkillReferences! !=0D
=0D
!MactoSkill class methodsFor: 'accessing' stamp: 'rws=20=0D
12/21/1999 00:48'!=0D
skillReferences: aThing=0D
=0D
^ SkillReferences :=3D aThing!=20=0D
!=0D
=0D
!MactoSkill class methodsFor: 'accessing' stamp: 'rws 12/16/1999=20=0D
05:16'!=0D
skills=0D
=0D
^ Skills! !=0D
=0D
=0D
!MactoSkill class methodsFor: 'utilities'=20=0D
stamp: 'rws 12/21/1999 00:40'!=0D
getAttDependants: aSymbol=0D
=0D
| attList tick=20=0D
result |=0D
=0D
     tick :=3D 1.=0D
     result :=3D OrderedCollection new.=0D
=0D
    =20=0D
attList :=3D (((self skills) at: aSymbol) at: 1).=0D
=0D
     attList do: [ :item |=20=0D
(tick odd)=0D
                                 ifTrue: [ result add: item.=0D
    =20=0D
                                        tick :=3D tick + 1. ]=0D
                =20=0D
                 ifFalse: [ tick :=3D tick + 1. ]. ].=0D
=0D
^ result asArray!=20=0D
!=0D
=0D
!MactoSkill class methodsFor: 'utilities' stamp: 'rws 12/20/1999=20=0D
06:10'!=0D
getAttReferences: aSymbol=0D
=0D
     ( (self attReferences) includesKey:=20=0D
aSymbol)=0D
          ifTrue: [ ^ (self attReferences at: aSymbol) ]=0D
         =20=0D
ifFalse: [ ^ nil ].! !=0D
=0D
!MactoSkill class methodsFor: 'utilities' stamp:=20=0D
'rws 12/21/1999 03:50'!=0D
getSkillDependants: aSymbol=0D
=0D
| depList tick result=20=0D
|=0D
=0D
     tick :=3D 1.=0D
     result :=3D OrderedCollection new.=0D
=0D
     ((self=20=0D
skills) includesKey: aSymbol)=0D
          ifFalse: [ ^ nil ].=0D
=0D
     depList :=3D=20=0D
(((self skills) at: aSymbol) at: 2).=0D
=0D
     depList do: [ :item | (tick odd)=0D
=20=0D
                                 ifTrue: [ result add: item.=0D
               =20=0D
                             tick :=3D tick + 1. ]=0D
                           =20=0D
      ifFalse: [ tick :=3D tick + 1. ]. ].=0D
=0D
^ result! !=0D
=0D
!MactoSkill class=20=0D
methodsFor: 'utilities' stamp: 'rws 12/21/1999 01:08'!=0D
getSkillReferences:=20=0D
aSymbol=0D
=0D
     ( (self skillReferences) includesKey: aSymbol)=0D
         =20=0D
ifTrue: [ ^ (self skillReferences at: aSymbol) ]=0D
          ifFalse: [ ^ nil=20=0D
].! !=0D
=0D
=0D
!MactoSkill class methodsFor: 'initialize-release' stamp: 'rws=20=0D
12/21/1999 00:32'!=0D
buildAttReferences=0D
=0D
| atts deps tempArray|=0D
=20=0D
    =20=0D
tempArray :=3D OrderedCollection new.=0D
     atts :=3D (MactoBasicAttribute=20=0D
basicAttributes).=0D
=0D
     self attReferences: Dictionary new.=0D
=0D
     atts do: [=20=0D
:att |=20=0D
          (self skills) keysDo: [ :skl | deps :=3D (MactoSkill=20=0D
getAttDependants: skl).=0D
                    (deps contains: [ :dep | dep =3D=20=0D
att ])=0D
                          ifTrue: [ tempArray add: skl ]. ].=0D
        =20=0D
  AttReferences at: att put: (tempArray asArray).=0D
          tempArray :=3D=20=0D
OrderedCollection new. ].! !=0D
=0D
!MactoSkill class methodsFor:=20=0D
'initialize-release' stamp: 'rws 12/21/1999 05:34'!=0D
buildSkillReferences=0D
=0D
|=20=0D
deps tempArray tempRefs goDeeper tempDeps temp2 storage |=0D
=20=0D
     tempArray=20=0D
:=3D OrderedCollection new.=0D
     self skillReferences: Dictionary new.=0D
=0D
    =20=0D
tempRefs :=3D Dictionary new.=0D
=0D
     (self skills) keysDo: [ :skl1 |=20=0D
         =20=0D
(self skills) keysDo: [ :skl2 | deps :=3D (MactoSkill getSkillDependants:=
=20=0D
skl2).=0D
                    (deps contains: [ :dep | dep =3D skl1 ])=0D
          =20=0D
                ifTrue: [ tempArray add: skl2 ]. ].=0D
          (tempArray=20=0D
isEmptyOrNil)=0D
                ifFalse: [ tempRefs at: skl1 put: (tempArray=20=0D
asArray).=0D
                           tempArray :=3D OrderedCollection new. ].=20=0D
].=0D
=0D
"^ self skillReferences: tempRefs"=0D
=0D
     storage :=3D OrderedCollection=20=0D
new.=0D
     goDeeper :=3D true.=0D
=0D
     tempRefs keysDo: [ :refKey | tempDeps :=3D=20=0D
OrderedCollection newFrom: (tempRefs at: refKey).=0D
                storage=20=0D
addAll: tempDeps.=0D
                [goDeeper] whileTrue: [ tempDeps do: [=20=0D
:item2 | (tempRefs includesKey: item2)=0D
                                     =20=0D
                                          ifTrue: [ temp2 :=3D (tempRefs at=
:=20=0D
item2) asOrderedCollection.=0D
                                                =20=0D
                                          tempDeps remove: item2.=0D
          =20=0D
                                                                           =
 =20=0D
    tempDeps addAll: temp2.=0D
                                                =20=0D
                                          storage addAll: temp2. ]=0D
         =20=0D
                                                                     =20=0D
ifFalse: [ storage add: item2.=0D
                                             =20=0D
                                              tempDeps remove: item2.] ].=
=0D
  =20=0D
                                                                           =
 =20=0D
(tempDeps isEmptyOrNil)=0D
                                                    =20=0D
                                ifTrue: [ goDeeper :=3D false ]=0D
              =20=0D
                                                                     =20=0D
ifFalse: [ goDeeper :=3D true.  ]. ].=0D
                                     =20=0D
self skillReferences at: refKey put: storage asArray.=20=0D
                     =20=0D
                 storage :=3D OrderedCollection new.].=0D
! !=0D
=0D
!MactoSkill class=20=0D
methodsFor: 'initialize-release' stamp: 'rws 12/21/1999=20=0D
00:29'!=0D
initSkills=0D
=0D
Skills :=3D Dictionary new.=0D
Skills at: #melee put:=20=0D
{{#strength. 4. #agility. 3. #dexterity. 1. #endurance. 2}. {}};=0D
      at:=20=0D
#dodge put: {{#strength. 2. #agility. 4. #dexterity. 3. #endurance. 1}.=20=
=0D
{}};=0D
      at: #persuade put: {{#intelligence. 3. #wisdom. 2. #charisma. 4.=20=
=0D
#willpower. 1}. {}};=0D
      at: #shock put: {{#strength. 1. #constitution. 4.=20=0D
#endurance. 2. #willpower. 3}. {}};=0D
      at: #sanity put: {{#intelligence.=20=0D
2. #wisdom. 3. #perception. 1. #willpower. 4}. {}};=0D
      at: #observe put:=20=0D
{{#perception. 5. #intelligence. 3. #wisdom. 2}. {}};=0D
      at: #swim put:=20=0D
{{#strength. 5. #endurance. 3. #agility. 2}. {}};=0D
      at: #missiles put:=20=0D
{{#perception. 4. #dexterity. 2. #intelligence. 2. #strength. 2}. {}};=0D
     =20=0D
at:      #notice put: {{#intelligence. 3}. {#observe. 7}};=0D
      at:     =20=0D
#search put: {{#perception. 3}. {#observe. 7}};=0D
      at:      #thieving=20=0D
put: {{#perception. 1. #dexterity. 2. #intelligence. 2}. {#observe. 5}};=0D
   =20=0D
   at:           #lockpick put: {{#intelligence. 1. #dexterity. 3}.=20=0D
{#thieving. 6}};=0D
      at:           #pickpocket put: {{#dexterity. 2}.=20=0D
{#thieving. 8}};=0D
      at:           #removetrap put: {{#intelligence. 1.=20=0D
#perception. 1}. {#thieving. 8}};=0D
      at:      #shields put: {{#strength.=20=0D
2}. {#melee. 3. #dodge. 5}};=0D
      at:           #roundshield put:=20=0D
{{#agility. 1. #dexterity. 1}. {#shields. 8}};=0D
      at:          =20=0D
#kiteshield put: {{#strength. 1. #dexterity. 1}. {#shields. 8}};=0D
      at:  =20=0D
    #axes put: {{#strength. 2. #agility. 2}. {#melee. 6}};=0D
      at:     =20=0D
#onehanded put: {{#agility. 2. #dexterity. 2}. {#melee. 6}};=0D
      at:      =20=0D
     #onehandbattleaxe put: {{#strength. 2}. {#onehanded. 3. #axes. 5}};=0D
   =20=0D
   at:           #onehandkatana put: {{#agility. 1. #dexterity. 1}.=20=0D
{#onehanded. 3. #swords. 5}};=0D
      at:           #onehandclub put:=20=0D
{{#agility. 1}. {#blunt. 5. #onehanded. 4}};=0D
      at:          =20=0D
#onehandhammer put: {{#agililty. 1}. {#blunt. 5. #onehanded. 4}};=0D
      at: =20=0D
     #twohanded put: {{#strength. 3. #endurance. 1}. {#melee. 6}};=0D
      at:=20=0D
           #twohandbattleaxe put: {{#strength. 3}. {#twohanded. 3. #axes.=
=20=0D
4}};=0D
      at:           #twohandsword put: {{#strength. 3}. {#twohanded. 3.=20=
=0D
#swords. 4}};=0D
      at:           #twohandkatana put: {{#strength. 2}.=20=0D
{#twohanded. 3. #swords. 5}};=0D
      at:           #twohandclub put:=20=0D
{{#strength. 1}. {#blunt. 5. #twohanded. 4}};=0D
      at:          =20=0D
#twohandhammer put: {{#strength. 1}. {#blunt. 5. #twohanded. 4}};=0D
      at: =20=0D
   #unarmed put: {{#strength. 1. #dexterity. 1. #agility. 1. #endurance. 1.=
=20=0D
#perception. 1}. {#melee. 3. #dodge. 2}};=0D
      at:    #bows put:=20=0D
{{#perception. 1. #strength. 2}. {#missiles. 7}};=0D
      at:          =20=0D
#crossbow put: {{#perception. 2}. {#bows. 8}};=0D
      at:           #longbow=20=0D
put: {{#strength. 2}. {#bows. 8}};=0D
      at:           #shortbow put:=20=0D
{{#dexterity. 2}.{#bows. 8}};=0D
      at:      #thrown put: {{#perception. 1.=20=0D
#dexterity. 1. #strength. 2}. {#missiles. 6}};=0D
      at:          =20=0D
#javelinthrown put: {{#dexterity. 2}. {#thrown. 4. #javelin. 4}};=0D
      at: =20=0D
          #daggerthrow put: {{#perception. 2}. {#thrown. 4. #dagger. 4}};=
=0D
  =20=0D
    at:           #spearthrow put: {{#strength. 2}. {#thrown. 4. #hafted.=
=20=0D
4}};=0D
      at:      #blunt put: {{#strength. 3}. {#melee. 7}};=0D
      at:    =20=0D
       #mace put: {{#strength. 2}. {#blunt. 8}};=0D
      at:           #flail=20=0D
put: {{#agility. 2}. {#blunt. 8}};=0D
      at:           #morningstar put:=20=0D
{{#dexterity. 2}. {#blunt. 8}};=0D
      at:      #swords put: {{#agility. 1.=20=0D
#dexterity. 1. #intelligence. 1}. {#melee. 7}};=0D
      at:          =20=0D
#scimitar put: {{#dexterity. 2}. {#swords. 8}};=0D
      at:          =20=0D
#broadsword put: {{#strength. 1}. {#swords. 9}};=0D
      at:          =20=0D
#longsword put: {{#strength. 2}. {#swords. 8}};=0D
      at:          =20=0D
#shortsword put: {{#agility. 1}. {#swords. 9}};=0D
      at:           #rapier=20=0D
put: {{#intelligence. 1}. {#swords. 9}};=0D
      at:      #knives put:=20=0D
{{#dexterity. 2. #agility. 3}. {#melee. 5}};=0D
      at:           #dagger=20=0D
put: {{#dexterity. 1}. {#knives. 9}};=0D
      at:      #hafted put:=20=0D
{{#strength. 1. #agility. 3}. {#melee. 6}};=0D
      at:           #staff put:=20=0D
{{#agility. 2}. {#hafted. 8}};=0D
      at:           #scyth put: {{#agility.=20=0D
1}. {#hafted. 9}};=0D
      at:           #pike put: {{#strength. 1}. {#hafted.=20=0D
9}};=0D
      at:           #javelin put: {{#dexterity. 1}. {#hafted. 9}};=0D
    =20=0D
  at:           #spear put: {{#strength. 1}. {#hafted. 9}}.! !=0D
=0D
!MactoSkill=20=0D
class methodsFor: 'initialize-release' stamp: 'rws 12/21/1999=20=0D
01:06'!=0D
initialize=0D
=0D
MaxBaseValue :=3D 100.=0D
MinBaseValue :=3D 0.=0D
=0D
self=20=0D
initSkills.=0D
self buildAttReferences.=0D
self buildSkillReferences.!=20=0D
!=0D
=0D
=0D
MactoSkill initialize!=0D

------=_NextPart_000_5b60e87e_7ad6adfe$51cab010--





More information about the Squeak-dev mailing list