Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d219a0a
added text name
fabiy3 Feb 17, 2019
75ee7db
Merge remote-tracking branch 'origin/master' into Fanuel
fabiy3 Feb 17, 2019
8049963
Merge remote-tracking branch 'origin/master' into Fanuel
fabiy3 Feb 17, 2019
a764b62
Merge remote-tracking branch 'origin/master' into Fanuel
fabiy3 Feb 18, 2019
5b3a2cd
Merge remote-tracking branch 'origin/master' into Fanuel
fabiy3 Feb 18, 2019
30d73fe
added planet class
evisalguero Feb 23, 2019
47d56c2
added solarSystem, related
evisalguero Feb 23, 2019
54924a9
Merge pull request #27 from matthew-so/evi2
evisalguero Feb 24, 2019
065001a
Merge remote-tracking branch 'origin/master' into Fanuel
fabiy3 Feb 24, 2019
3736dd8
added universe class and populated universe with various solar systems
fabiy3 Feb 25, 2019
e6ea716
Merge pull request #31 from matthew-so/Fanuel
kmontalvo3 Feb 25, 2019
d8a1284
-have to fix universe.java
kmontalvo3 Feb 25, 2019
04d6817
- made ui for universe generation
kmontalvo3 Feb 25, 2019
6bdb1f2
- made ui for universe generation
kmontalvo3 Feb 25, 2019
20abfcd
Merge pull request #33 from matthew-so/Kyser
fabiy3 Feb 25, 2019
7de9f8d
Added Planetary/Solar System/Good Functionality
matthew-so Mar 3, 2019
ed682bc
Merge remote-tracking branch 'origin/matthew' into matthew
kmontalvo3 Mar 3, 2019
e406185
-setup UI for marketplace
kmontalvo3 Mar 4, 2019
212012a
-setup UI for marketplace
kmontalvo3 Mar 4, 2019
63b4676
Merge remote-tracking branch 'origin/matthew' into matthew
kmontalvo3 Mar 4, 2019
912e933
Merge branch 'matthew' into Kyser
kmontalvo3 Mar 4, 2019
aab38bb
-working on marketplace functionality
kmontalvo3 Mar 5, 2019
f8d5058
-working on marketplace functionality
kmontalvo3 Mar 6, 2019
0c27d66
-market place functionaly almost done
kmontalvo3 Mar 6, 2019
5b09f13
-market place functionaly almost done
kmontalvo3 Mar 6, 2019
d87070c
-market functionality is DONE
kmontalvo3 Mar 6, 2019
ff68186
-market functionality is DONE
kmontalvo3 Mar 6, 2019
852ce31
Merge pull request #39 from matthew-so/Kyser
fabiy3 Mar 6, 2019
87db684
added travel layout xml
evisalguero Mar 7, 2019
8ddd001
connected layout and data to travel
evisalguero Mar 10, 2019
5a9515e
connected layout and data to travel
evisalguero Mar 10, 2019
38e21e9
Merge pull request #41 from matthew-so/evi4
kmontalvo3 Mar 30, 2019
22aa44c
-implemented random events...may work on it some more
kmontalvo3 Mar 30, 2019
ed6dc6e
Unused imports removed
matthew-so Apr 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
</activity>
<activity android:name=".views.UniverseActivity">
</activity>
<activity android:name=".views.MarketplaceActivity">
</activity>
<activity android:name=".views.StartPlayActivity">
</activity>
<activity android:name=".views.TravelActivity">
</activity>
</application>

</manifest>
40 changes: 35 additions & 5 deletions app/src/main/java/com/example/spacetrader/entity/Good.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.spacetrader.entity;

import com.example.spacetrader.entity.TechLevel;
public enum Good {
WATER("Water", TechLevel.ZERO, TechLevel.ZERO, TechLevel.TWO, 30, 3, 4, RandomSolarEvent.DROUGHT, Resource.FOUR, Resource.THREE, 30, 50),
FURS("Furs", TechLevel.ZERO, TechLevel.ZERO, TechLevel.ZERO, 250, 10, 10, RandomSolarEvent.COLD, Resource.SEVEN, Resource.EIGHT, 230, 280),
Expand All @@ -25,6 +25,9 @@ public enum Good {
private Resource er; //high-price condition
private int mtl; //min price offered in space trade
private int mth; //max price offered in space trade
private int quantity;
private int price; //this is the price that was calculated on onEnter in Solarsystem


Good(String name, TechLevel mtlp, TechLevel mtlu, TechLevel ttp, int base, int ipl, int var, RandomSolarEvent ie, Resource cr, Resource er, int mtl, int mth) {
this.name = name;
Expand All @@ -39,6 +42,7 @@ public enum Good {
this.er = er;
this.mtl = mtl;
this.mth = mth;
quantity = 0;
}

public String toString() {
Expand Down Expand Up @@ -97,6 +101,10 @@ public int getBasePrice(TechLevel planetech) {
return base + ipl*planetech.compareTo(TechLevel.ZERO);
}

public void setPrice(int price) {
this.price = price;
}

public int specialResources(Resource resource, int baseprice) {
if (cr != null) {
if (resource.equals(cr)) {
Expand Down Expand Up @@ -134,30 +142,40 @@ public int sellPrice(int buyprice, int traderskill) {
}


/**
* Used for onEnter method in SolarSystem.java
* @param soltech
* @return
*/
public boolean canBuy(TechLevel soltech) {
return soltech.compareTo(mtlu) >= 0;
}

/**
* Used for onEnter method in SolarSystem.java
* @param soltech
* @return
*/
public boolean canSell(TechLevel soltech) {
return soltech.compareTo(mtlp) >= 0;
}

public int getQuantity(TechLevel soltech, int size, Resource resource, RandomSolarEvent solar) {
public int calculateQuantity(TechLevel soltech, int size, Resource resource, RandomSolarEvent solar) {
int quantity = 9 + ((int) (5 * Math.random())) - Math.abs(ttp.compareTo(soltech)) * (1 + size);
if (name.equals("Robots") || name.equals("Narcotics")) {
quantity *= 5;
quantity /= 6;
quantity += 1;
}
if (resource.equals(cr)) {
if (resource != null && resource.equals(cr)) {
quantity *= 4;
quantity /= 3;
}
if (resource.equals(er)) {
if (er != null &&resource.equals(er)) {
quantity *= 3;
quantity /= 4;
}
if (solar.equals(ie)) {
if (ie != null && solar != null && solar.equals(ie)) {
quantity /= 5;
}
quantity += (int) (10 * Math.random());
Expand All @@ -167,4 +185,16 @@ public int getQuantity(TechLevel soltech, int size, Resource resource, RandomSol
}
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}

public int getQuantity() {
return quantity;
}

public int getPrice() {
return price;
}
}
4 changes: 4 additions & 0 deletions app/src/main/java/com/example/spacetrader/entity/Planet.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ public class Planet {
public Planet(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
135 changes: 135 additions & 0 deletions app/src/main/java/com/example/spacetrader/entity/Player.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.example.spacetrader.entity;

import com.example.spacetrader.model.Game;
import com.example.spacetrader.views.ConfigurationActivity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Map;

public class Player implements Serializable {

private String name;

private int credits;
Expand All @@ -19,6 +25,16 @@ public class Player implements Serializable {

private Ship ship;

private SolarSystem currentSolarSystem;

private ArrayList<Good> playerGoods;

private int inventorySpace;

private Map<Good,Integer> howMuchPlayerCanBuy;

private Map<Good,Integer> whatPlayerCanSell;

public Player(String name, int trader, int fighter, int pilot, int engineer) {
this.name = name;
this.trader = trader;
Expand All @@ -27,7 +43,10 @@ public Player(String name, int trader, int fighter, int pilot, int engineer) {
this.engineer = engineer;
credits = 1000;
ship = new Ship(Ship.ShipType.GNAT);
inventorySpace = ship.getCargoCapacity();
totalPoints = 16;
playerGoods = new ArrayList<>();

}


Expand All @@ -39,6 +58,75 @@ public int calculatePointsLeft() {
return totalPoints;
}

/**
* The buttons on the marketplace are activated or deactivated based on this value
* determines whether or not the player can buy the good
* @param good the good the player wishes to buy
* @return true if the player can buy the good, false if not
*/
public boolean canBuy(Good good) {
if (this.getCredits() <= 0
|| inventorySpace == 0
|| this.getCurrentSolarSystem().getBuyGoodPrice(good) > credits) {
return false;
} else {
return true;
}
}

/**
* The buttons on the marketplace are activated or deactivated based on this value
* checks if the player can sell a good
* @param good the good the player wants to sell
* @return true if the player can false if he or she cannot
*/
public boolean canSell(Good good) {
if (!playerGoods.contains(good)){
return false;
} else {
return true;
}
}

/**
* the player buys a good
* @param good the good the player wishes to buy
*/
public boolean buy(Good good) {
if (canBuy(good) == false) {
return false;
} else {
this.setCredits(this.credits -= good.getPrice());
if (!playerGoods.contains(good)) {
playerGoods.add(good);
}
this.inventorySpace--;
good.setQuantity(good.getQuantity() + 1);
return true;
}

}

/**
* player sells a good
* @param good
*/
public boolean sell(Good good) {
if (!canSell(good) || good.getQuantity() == 0) {

return false;
} else {
this.setCredits(credits += good.getPrice());
this.inventorySpace++;
good.setQuantity(good.getQuantity() - 1);
return true;
}



}



public String getName() {
return name;
Expand Down Expand Up @@ -67,4 +155,51 @@ public int getEngineer() {
public Ship getShipType() {
return ship;
}

public void setCredits(int credits) {
this.credits = credits;
}

public Game getGame() {return ConfigurationActivity.newGame; }

public SolarSystem getCurrentSolarSystem() {
return currentSolarSystem;
}

/**sets the current solar system of player*/
public void setCurrentSolarSystem(SolarSystem s) {
currentSolarSystem = s;
howMuchPlayerCanBuy = currentSolarSystem.getQuantityBuy();
}

/**
* Returns a filtered list of player goods.
* Goods must have valid prices.
* @return an ArrayList of Goods
*/
public ArrayList<Good> getPlayerGoods() {
return playerGoods;

}



public void addToPlayerGoods(Good good) {
playerGoods.add(good);
}

/**This method is only called when the solar system is assigned to the Player**/
private void setHowMuchPlayerCanBuy() {
howMuchPlayerCanBuy = currentSolarSystem.getQuantityBuy();
}

private void setWhatPlayerCanSell() {
whatPlayerCanSell = currentSolarSystem.getBuyGood();
}

public int getInventorySpace() {
return inventorySpace;
}

}

Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
package com.example.spacetrader.entity;

import java.util.Random;

public enum RandomSolarEvent {
UNEVENTFUL, DROUGHT, COLD, CROPFAIL, WAR, BOREDOM, PLAGUE, LACKOFWORKERS;
UNEVENTFUL("Uneventful"), DROUGHT("Drought"), COLD("Cold"), CROPFAIL("Cropfail"), WAR("War"), BOREDOM("Boredom"),
PLAGUE("Plague"), LACKOFWORKERS("Lack of Workers");

private String val;

RandomSolarEvent(String val) {
this.val = val;
}

public String toString() {
return val;
}

/**
* Pick a random value of the BaseColor enum.
* @return a random BaseColor.
*/
public static RandomSolarEvent getRandomSolarEvent() {
Random random = new Random();
RandomSolarEvent myRandomEvent = values()[random.nextInt(values().length)];
return myRandomEvent;
}
}
Loading