DaDarkWizard / TextAdventure

An Awesome Text Adventure
3 stars 0 forks source link

Find Getters #2

Closed DaDarkWizard closed 4 years ago

DaDarkWizard commented 4 years ago

Find the classes that return an arraylist itself rather than a copy

AiryTheDragon commented 4 years ago

I did a search in IntelliJ for the usages of the string "ArrayList" in the project and am reviewing the classes that mention ArrayList,

AiryTheDragon commented 4 years ago

These are the classes that mention "ArrayList" and my assessment of them. There are 113 mentions of the term

In the TextAdventure src folder: CustomAdventureClient: (3 mentions) Two ArrayLists are created: input and output. They are created as fields and not returned in a method.

TechAdventure: (3 mentions) rooms is declared as an ArrayList field, it is not returned in a method

In the CombatHandler folder: Combatant: (3 mentions) In the interface class getWeapons is declared as a method to return an ArrayList variable. getWords is declared as a method to return an ArrayList variable. These implemented methods should be investigated.

CombatGroup: (8 mentions) combatants, CombatGroups and players are set as ArrayList fields combatants is passed as a ArrayList parameter to the constructor, then set to the object, meaning the object and the calling program have the same references. I have marked several places in this file to review.

In the GamePieces folder: Furniture: validNames is an ArrayList field, it is not returned in a method.

Room: players, interactables and npcs are ArrayList fields. These are returned in method calls an I have marked reviewing them.

That is as far as I have gotten in marking those locations right now.

AiryTheDragon commented 4 years ago

Continuing searching through code...

In the Generator folder LevelGenerator, (3 mentions) rooms is a private field and is returned in a method, but it is generated in the method and looks alright.

In the NPCHandler folder Boss: (6 mentions) dataStorage is an ArrayList field. getDataStorage is a method that returns the ArrayList field and I flagged it. getWeapons is a method that you would think would return an ArrayList, but it returns null for some reason. I flagged this. getCombatWords is a method that returns an ArrayList, I think this one is alright, returning an ArrayList with one element in it.

DefaultNPC: (7 mentions) weapons, words, and datastorage are ArrayList fields. It has getDataStorage, getWeapons and getCombatWords methods that return ArrayLists, and I flagged them.

DireBat: (5 mentions) It looks like there is a cast to an ArrayList and call to a method in the class using it, but this does not look to be a problem.

Dragon: (5 mentions) There are some references to an ArrayList, I don't understand everything going on here, but I flagged the item that couldn't be fixed before

Monster:(5 mentions) I don't see any ArrayList fields here. the getDataStorage and getWeapons which return ArrayList objects return null, and the get CombatWords returns a created ArrayList with 4 hits.

NPC: (10 mentions) npcs is a static ArrayList field. weapons, combatWords and dataStorage are ArrayList fields. This method should undergo some extra review. I flagged the constructors; particularly with these I believe you're going to want deep copies of the data. It also has a getDataStorage, getWords, and getWeapons methods to update that I flagged.

NPCTemplate: (4 mentions) This template has the methods getDataStorage, getWords, and getWeapons, but has no implementation, so they should be fine.

In the PlayerHandler folder InputHandler: (4 mentions) possibleMatchesInter and possibleMatchesHod are local variables in the handleInput method. I do not see them causing problems. I also corrected the pickup and drop item bugs (probably). I made a note address multiple of the same item.

Player: (13 mentions) players, blockedPlayers, items, equipped, and words are class fields. getPossibleAttackCommands returns an ArrayList that is generated in the method and should be fine. I marked getPlayers, getEquipped, getInventory, getWords, and getWeapons as needing to be updated.

In the PlayerHandler.Persistence folder CharacterCreating: (3 mentions) There is a static ArrayList called characterCreators The method getCharacterCreators returns the ArrayList and I have flagged it for review and possible changes.

CharacterLoading: (2 mentions) characterLoaders is a static ArrayList. I do not see it returned in a method.

In the PlayerHandler.UI folder CombatFrame: (3 mentions) attackCommands and combatLog are ArrayList class fields. attackCommands is not used and combatLog not returned in a method call.

SizableFrame: (4 mentions) lines is an ArrayList class field. newLines is an ArrayList method variable in add list is an ArrayList method variable in clearFrame. They are not returned in method calls.

In the World.Tutorial folder InfoGiver: (5 mentions) lines is an ArrayList class field. storedLines is an ArrayList variable inside an event. There is already a problem comment before it so I flagged it with a todo.

Tutorial: (3 mentions) batBounds and deletable are method variables used in constructor to create the bat and dragon.

Well, that's all the references I see, so I consider this part completed.