Created
April 30, 2019 04:58
-
-
Save IceCereal/bb594b36dc11d0f2002ace033fe388f5 to your computer and use it in GitHub Desktop.
Gain2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Random; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Scanner; | |
class ability{ | |
Map<String, Integer> Abilities = new HashMap<String, Integer>(); | |
/* | |
Extra Abilites that the player could have: defaults [None] | |
Every Ability created can have called Ability_Reductor: | |
Does Ability reduce every round: defaults [0] | |
Ex: | |
Mana: 200 | |
Mana_Reductor: 3 | |
*/ | |
public int addAbility(String abilityName, int abilityValue){ | |
Abilities.put(abilityName, abilityValue); | |
return 1; | |
} | |
public int addAbility_Reductor(String abilityName, int ability_Reductor){ | |
if (checkAbilityExist(abilityName)){ | |
StringBuilder abilityReductorBuilder = new StringBuilder(); | |
abilityReductorBuilder.append(abilityName); | |
abilityReductorBuilder.append("_Reductor"); | |
String abilityName_Reductor = abilityReductorBuilder.toString(); | |
this.addAbility(abilityName_Reductor, ability_Reductor); | |
return 1; | |
} | |
return -1; | |
} | |
public boolean checkAbilityExist(String abilityName){ | |
return Abilities.containsKey(abilityName); | |
} | |
public int getAbilityValue(String abilityName){ | |
if (checkAbilityExist(abilityName)) | |
return Abilities.get(abilityName); | |
return Integer.MIN_VALUE; | |
} | |
public Map<String, Integer> getAllAbilities(){ | |
return Abilities; | |
} | |
public int deleteAbility(String abilityName){ | |
Abilities.remove(abilityName); | |
return 1; | |
} | |
} | |
class gainObject{ | |
private String name; // Object name: defaults ["Object-Ice"] | |
private String description_long; // Long Description of Object: defaults [null] | |
private String description_short; // Short Description of Object: defaults [null] | |
private int levelUsable; // The level at which the main player can unlock it: defaults [0] | |
private int objectSize; // Size of the Object: defaults [1] | |
private int objectType; | |
/* | |
Object Types: | |
0 - Consumable | |
1 - Attack | |
*/ | |
private int objectType_Value; // The value of the object, [i.e. Knife: Attack: 10]: defaults [1] | |
gainObject(){ | |
name = "Object-Ice"; | |
description_long = null; | |
description_short = null; | |
levelUsable = 0; | |
objectSize = 1; | |
objectType_Value = 1; | |
} | |
public int setName(String sentName){ | |
name = sentName; | |
return 1; | |
} | |
public int setDescription_Long(String sentDescription_Long){ | |
description_long = sentDescription_Long; | |
return 1; | |
} | |
public int setDescription_Short(String sentDescription_Short){ | |
description_short = sentDescription_Short; | |
return 1; | |
} | |
public int setLevelUsable(int sentLevelUsable){ | |
levelUsable = sentLevelUsable; | |
return 1; | |
} | |
public int setObjecSize(int sentObjectSize){ | |
objectSize = sentObjectSize; | |
return 1; | |
} | |
public int setObjectType(int sentObjectType, int sentObjectType_Value){ | |
if ( (sentObjectType == 1) || (sentObjectType == 0) ){ | |
objectType = sentObjectType; | |
objectType_Value = sentObjectType_Value; | |
return 1; | |
} | |
return 0; | |
} | |
public String getName(){ | |
return name; | |
} | |
public String getDescripitionLong(){ | |
return description_long; | |
} | |
public String getDescripitionShort(){ | |
return description_short; | |
} | |
public int getLevelUsable(){ | |
return levelUsable; | |
} | |
public int getObjectSize(){ | |
return objectSize; | |
} | |
public int getObjectType(){ | |
return objectType; | |
} | |
public int consumeValue(){ | |
if (objectType == 0){ | |
return objectType_Value; | |
} | |
return Integer.MIN_VALUE; | |
} | |
public int attackValue(){ | |
if (objectType == 1){ | |
return objectType_Value; | |
} | |
return Integer.MIN_VALUE; | |
} | |
} | |
class mainPlayer{ | |
String name; // Character name: defaults ["Ice"] | |
String description_long; // Long Description of Character: defaults [null] | |
String description_short; // Short Description of Character: defaults [null] | |
int level; // Character Level: defaults [0] | |
int healthPoints; // HP: defaults [100] | |
int healthPoints_Reductor; // Does HP reduce every round: defaults [0] | |
int experiencePoints; // XP: defaults [0] | |
// IMPORT `ABILITES` & CREATE INSTANCE | |
// IMPORT `GAIN-OBJECT` & USE IT TO CREATE INSTANCE | |
mainPlayer(){ | |
name = "Ice"; | |
description_long = null; | |
description_short = null; | |
level = 0; | |
healthPoints = 100; | |
healthPoints_Reductor = 0; | |
experiencePoints = 0; | |
} | |
public int setName(String sentName){ | |
this.name = sentName; | |
return 1; | |
} | |
public int setDescription_Long(String sentDescLong){ | |
this.description_long = sentDescLong; | |
return 1; | |
} | |
public int setDescription_Short(String sentDescShort){ | |
this.description_short = sentDescShort; | |
return 1; | |
} | |
public int setLevel(int sentLevel){ | |
this.level = sentLevel; | |
return 1; | |
} | |
public int setHP(int sentHealthPoints){ | |
this.healthPoints = sentHealthPoints; | |
return 1; | |
} | |
public int setHP_Reductor(int sentHealthPoints_Reductor){ | |
this.healthPoints_Reductor = sentHealthPoints_Reductor; | |
return 1; | |
} | |
public int setXP(int sentExperiencePoints){ | |
this.experiencePoints = sentExperiencePoints; | |
return 1; | |
} | |
} | |
class NPC{ | |
String name; // Name of the NPC: defaults ["NPC-Ice"] | |
String description_long; // Long Description of Character: defaults [null] | |
String description_short; // Short Description of Character: defaults [null] | |
Map<Integer, String> DescriptionMap = new HashMap<Integer, String>(); | |
/* | |
Pull up this description when I say so, essentially. | |
0 - Okay, go to that room | |
1 - You will die soon | |
2 - blah de blah de blah | |
<This action requires this Description> | |
*/ | |
int healthPoints; // HP: defaults [100] | |
int healthPoints_Reductor; // Does HP reduce every round: defaults [0] | |
int typeNPC; | |
/* | |
NPC Types: | |
0 - Friendly | |
1 - Guide | |
2 - Enemy | |
*/ // defaults [0] | |
int attackingLevel; // Level at which the NPC attacks: defaults [0] (range 0 - 10) | |
public NPC(){ | |
name = "NPC-Ice"; | |
description_long = null; | |
description_short = null; | |
healthPoints = 100; | |
healthPoints_Reductor = 0; | |
typeNPC = 0; | |
attackingLevel = 0; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public void setDescription_long(String description_long) { | |
this.description_long = description_long; | |
} | |
public void setDescription_short(String description_short) { | |
this.description_short = description_short; | |
} | |
public void setHealthPoints(int healthPoints) { | |
this.healthPoints = healthPoints; | |
} | |
public void setHealthPoints_Reductor(int healthPoints_Reductor) { | |
this.healthPoints_Reductor = healthPoints_Reductor; | |
} | |
public int setTypeNPC(int typeNPC) { | |
if ( (typeNPC >= 0) && (typeNPC <= 2)){ | |
this.typeNPC = typeNPC; | |
return 1; | |
} | |
return -1; | |
} | |
public void setAttackingLevel(int attackingLevel) { | |
if ((attackingLevel >=0) && (attackingLevel <=10)) | |
this.attackingLevel = attackingLevel; | |
if (attackingLevel > 10) | |
this.attackingLevel = 10; | |
if (attackingLevel < 0) | |
this.attackingLevel = 0; | |
} | |
public void addTo_DescriptionMap(int key, String value) { | |
DescriptionMap.put(key, value); | |
} | |
public String getName() { | |
return name; | |
} | |
public String getDescription_long() { | |
return description_long; | |
} | |
public String getDescription_short() { | |
return description_short; | |
} | |
public int getHealthPoints() { | |
return healthPoints; | |
} | |
public int getHealthPoints_Reductor() { | |
return healthPoints_Reductor; | |
} | |
public int getTypeNPC() { | |
return typeNPC; | |
} | |
public int getAttackingLevel() { | |
return attackingLevel; | |
} | |
public Map<Integer, String> getDescriptionMap() { | |
return DescriptionMap; | |
} | |
public int Attack(){ | |
Random rand = new Random(3010); | |
int attackMagnitude = rand.nextInt(attackingLevel); | |
return attackMagnitude; | |
// NOTE: Core will adjust the actual value to be scaled depending on MP's HP | |
} | |
} | |
class Door{ | |
private List<Integer> coordinatesFrom; // Door opens from these coords | |
private List<Integer> coordinatesTo; // Door opens to these coords | |
Boolean key_required; // Boolean that checks whether the key is required | |
int key_id; // If key_required: True, key_id represents the key id for the door | |
public Door(){ | |
coordinatesFrom.add(0); | |
coordinatesFrom.add(0); | |
coordinatesTo.add(0); | |
coordinatesTo.add(0); | |
key_required = false; | |
key_id = -1; | |
} | |
public int setFromCoords(List<Integer> sentCoordinatesFrom){ | |
coordinatesFrom.remove(0); | |
coordinatesFrom.remove(1); | |
coordinatesFrom.add(sentCoordinatesFrom.get(0)); | |
coordinatesFrom.add(sentCoordinatesFrom.get(1)); | |
return 1; | |
} | |
public int setToCoords(List<Integer> sentCoordinatesTo){ | |
coordinatesTo.remove(0); | |
coordinatesTo.remove(1); | |
coordinatesTo.add(sentCoordinatesTo.get(0)); | |
coordinatesTo.add(sentCoordinatesTo.get(1)); | |
return 1; | |
} | |
public int setCoords(List<Integer> sentCoordinatesFrom, List<Integer> sentCoordinatesTo){ | |
coordinatesFrom.remove(0); | |
coordinatesFrom.remove(1); | |
coordinatesFrom.add(sentCoordinatesFrom.get(0)); | |
coordinatesFrom.add(sentCoordinatesFrom.get(1)); | |
coordinatesTo.remove(0); | |
coordinatesTo.remove(1); | |
coordinatesTo.add(sentCoordinatesTo.get(0)); | |
coordinatesTo.add(sentCoordinatesTo.get(1)); | |
return 1; | |
} | |
public int setKeyRequired(Boolean sentKey_Required){ | |
key_required = sentKey_Required; | |
return 1; | |
} | |
public int setKeyID(int sentKey_ID){ | |
key_id = sentKey_ID; | |
return 1; | |
} | |
public List<Integer> getCoordinatesFrom(){ | |
return coordinatesFrom; | |
} | |
public List<Integer> getCoordinatesTo(){ | |
return coordinatesTo; | |
} | |
public List<List> getCoordinates(){ | |
List<List> coordinates = new ArrayList<List>(); | |
coordinates.add(coordinatesFrom); | |
coordinates.add(coordinatesTo); | |
return coordinates; | |
} | |
public Boolean getKeyRequired(){ | |
return key_required; | |
} | |
public int getKeyID(){ | |
return key_id; | |
} | |
} | |
class Key{ | |
private int key_id; // Engine set key_id | |
private Boolean hasKey; // Not sure if this will be useful, but I'll keep it here for now | |
public Key(){ | |
key_id = 0; | |
hasKey = false; | |
} | |
public int getKey_id() { | |
return key_id; | |
} | |
public Boolean getHasKey() { | |
return hasKey; | |
} | |
public void setKey_id(int key_id) { | |
this.key_id = key_id; | |
} | |
public void setHasKey(Boolean hasKey) { | |
this.hasKey = hasKey; | |
} | |
} | |
class Room{ | |
private List<Integer> coordinates; // The X, Y coordinates of the room. Internal property set by Core Engine | |
private String name; // Room name: defaults ["Unknown"] | |
private String description_long; // Long Description of Room: defaults ["There seems to be nothing special here"] | |
private String description_short; // Short Description of Room: defaults ["There seems to be nothing special here"] | |
// TODO: implement an array of Gainbjects | |
public Room(List<Integer> sentCoordinates){ | |
coordinates = new ArrayList<Integer>(); | |
coordinates.add(sentCoordinates.get(0)); | |
coordinates.add(sentCoordinates.get(1)); | |
name = "Unknown"; | |
description_long = "There seems to be nothing special about here"; | |
description_short = "There seems to be nothing special about here"; | |
} | |
public int changeCoordinates(List<Integer> sentCoordinates){ | |
coordinates.remove(0); | |
coordinates.remove(1); | |
coordinates.add(sentCoordinates.get(0)); | |
coordinates.add(sentCoordinates.get(1)); | |
return 1; | |
} | |
public int setName(String sentRoomName){ | |
name = sentRoomName; | |
return 1; | |
} | |
public int setDescription_Long(String sentDescription_Long){ | |
description_long = sentDescription_Long; | |
return 1; | |
} | |
public int setDescription_Short(String sentDescription_Short){ | |
description_short = sentDescription_Short; | |
return 1; | |
} | |
public List<Integer> getCoordinates(){ | |
return coordinates; | |
} | |
public String getName(){ | |
return name; | |
} | |
public String getDescription_Long(){ | |
return description_long; | |
} | |
public String getDescription_Short(){ | |
return description_short; | |
} | |
} | |
class buildGame{ | |
String authorName; // defaults ["IceCereal's-Discipile"] | |
String gameName; // defaults ["The-Game-Of-Ice"] | |
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); | |
Date curDate = new Date(); | |
public buildGame(){ | |
authorName = "IceCereal's-Discipile"; | |
gameName = "The-Game-Of-Ice"; | |
} | |
public String getAuthorName() { | |
return authorName; | |
} | |
public void setAuthorName(String authorName) { | |
this.authorName = authorName; | |
} | |
public String getGameName() { | |
return gameName; | |
} | |
public void setGameName(String gameName) { | |
this.gameName = gameName; | |
} | |
public static void main(String[] args) { | |
buildGame bg = new buildGame(); | |
Scanner scan = new Scanner(System.in); | |
System.out.println("Enter Game Author:\t"); | |
bg.setAuthorName(scan.next()); | |
System.out.println("Enter Game Name:\t"); | |
bg.setGameName(scan.next()); | |
mainPlayer mp = new mainPlayer(); | |
System.out.println("Main Character's Name:\t"); | |
mp.setName(scan.next()); | |
System.out.println("Main Character's Health:\t"); | |
mp.setHP(scan.nextInt()); | |
System.out.println("Main Character's Health Reductor:\t"); | |
mp.setHP_Reductor(scan.nextInt()); | |
List<Integer> Coords = new ArrayList<Integer>(); | |
Coords.add(0);Coords.add(0); | |
scan.close(); | |
ability abilities = new ability(); | |
abilities.addAbility("mana", 100); | |
System.out.println(abilities.getAllAbilities()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment