started on new days and random events
This commit is contained in:
parent
042f41df71
commit
267a66b434
35
slangin.ino
35
slangin.ino
|
@ -37,26 +37,20 @@ enum GameState {
|
||||||
|
|
||||||
enum GameLocation {
|
enum GameLocation {
|
||||||
LOC_BRONX = 0,
|
LOC_BRONX = 0,
|
||||||
LOC_GHETTO,
|
LOC_GHETTO = 1,
|
||||||
LOC_CENTRAL_PARK,
|
LOC_CENTRAL_PARK = 2,
|
||||||
LOC_MANHATTEN,
|
LOC_MANHATTEN = 3,
|
||||||
LOC_CONEY_ISLAND,
|
LOC_CONEY_ISLAND = 4,
|
||||||
LOC_BROOKLYN
|
LOC_BROOKLYN = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Drug {
|
enum Drug {
|
||||||
DRUG_COCAINE = 0,
|
DRUG_COCAINE = 0,
|
||||||
DRUG_HEROINE,
|
DRUG_HEROINE = 1,
|
||||||
DRUG_ACID,
|
DRUG_ACID = 2,
|
||||||
DRUG_WEED,
|
DRUG_WEED = 3,
|
||||||
DRUG_SPEED,
|
DRUG_SPEED = 4,
|
||||||
DRUG_LUDES
|
DRUG_LUDES = 5
|
||||||
};
|
|
||||||
|
|
||||||
enum DialogType {
|
|
||||||
DIALOG_INFO = 0,
|
|
||||||
DIALOG_YESNO,
|
|
||||||
DIALOG_AMOUNT
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t PROGMEM spriteDollar[] = {
|
const uint8_t PROGMEM spriteDollar[] = {
|
||||||
|
@ -77,7 +71,6 @@ GameState sGameState;
|
||||||
GameState sPreviousGameState;
|
GameState sPreviousGameState;
|
||||||
int sCurrentDay;
|
int sCurrentDay;
|
||||||
int sDrugPrices[6];
|
int sDrugPrices[6];
|
||||||
int sRandomEvent;
|
|
||||||
int sCurrentDrug;
|
int sCurrentDrug;
|
||||||
long sCurrentQty;
|
long sCurrentQty;
|
||||||
long sQtyMax;
|
long sQtyMax;
|
||||||
|
@ -181,9 +174,9 @@ void loop() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_JET_MENU: {
|
case STATE_JET_MENU: {
|
||||||
String title = F("Jet from ");
|
|
||||||
title = title + lookupLocation(pLocation);
|
|
||||||
drawStatusBar();
|
drawStatusBar();
|
||||||
|
String title = F("Jet from ");
|
||||||
|
title += lookupLocation(pLocation);
|
||||||
drawTitle(title);
|
drawTitle(title);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
int loc = i >= pLocation ? i + 1 : i;
|
int loc = i >= pLocation ? i + 1 : i;
|
||||||
|
@ -477,9 +470,9 @@ void buildDrugMenu(int extra[6]) {
|
||||||
int colMax = i < 3 ? col1Max : col2Max;
|
int colMax = i < 3 ? col1Max : col2Max;
|
||||||
menu[i] = lookupDrug(i) + F(" ");
|
menu[i] = lookupDrug(i) + F(" ");
|
||||||
for (int s = 0; s < colMax - lengths[i]; s++) {
|
for (int s = 0; s < colMax - lengths[i]; s++) {
|
||||||
menu[i] = menu[i] + F(" ");
|
menu[i] += F(" ");
|
||||||
}
|
}
|
||||||
menu[i] = menu[i] + extra[i];
|
menu[i] += extra[i];
|
||||||
}
|
}
|
||||||
menuLength = 6;
|
menuLength = 6;
|
||||||
menuCols = true;
|
menuCols = true;
|
||||||
|
|
167
states.ino
167
states.ino
|
@ -21,8 +21,6 @@ void initializeNewGame() {
|
||||||
|
|
||||||
sCurrentDay = 0;
|
sCurrentDay = 0;
|
||||||
incrementDay(); // start on day 1
|
incrementDay(); // start on day 1
|
||||||
|
|
||||||
sRandomEvent = 0; // no event on first day
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void incrementDay() {
|
void incrementDay() {
|
||||||
|
@ -40,6 +38,152 @@ void incrementDay() {
|
||||||
sDrugPrices[DRUG_LUDES] = (random(5) + 1) * 10;
|
sDrugPrices[DRUG_LUDES] = (random(5) + 1) * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void newDayRandomEvent() {
|
||||||
|
const int eventId = random(20);
|
||||||
|
sPreviousGameState = STATE_TURN_MENU;
|
||||||
|
dialogSmall = false;
|
||||||
|
switch (eventId) {
|
||||||
|
case 1:
|
||||||
|
dialog[0] = "Rival dealers are";
|
||||||
|
dialog[1] = "selling cheap";
|
||||||
|
dialog[2] = "ludes!!!";
|
||||||
|
dialogLength = 3;
|
||||||
|
sDrugPrices[DRUG_LUDES] = 2;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
dialog[0] = "Weed prices have";
|
||||||
|
dialog[1] = "bottomed out!!!";
|
||||||
|
dialogLength = 2;
|
||||||
|
sDrugPrices[DRUG_WEED] = 122;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
dialog[0] = "Pigs are selling";
|
||||||
|
dialog[1] = "cheap heroine";
|
||||||
|
dialog[2] = "from last week's";
|
||||||
|
dialog[3] = "raid!!!!";
|
||||||
|
dialogLength = 4;
|
||||||
|
sDrugPrices[DRUG_HEROINE] = random(1150) + 850;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
dialog[0] = "Addicts are";
|
||||||
|
dialog[1] = "buying heroine";
|
||||||
|
dialog[2] = "at outrageous";
|
||||||
|
dialog[3] = "prices!!!";
|
||||||
|
dialogLength = 4;
|
||||||
|
sDrugPrices[DRUG_HEROINE] = random(25001) + 18000;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
case 7:
|
||||||
|
dialog[0] = "Pigs made a big";
|
||||||
|
dialog[1] = "coke bust! Prices";
|
||||||
|
dialog[2] = "are outrageous!!!!";
|
||||||
|
dialogLength = 3;
|
||||||
|
sDrugPrices[DRUG_COCAINE] = random(60001) + 80000;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
dialog[0] = "You were mugged";
|
||||||
|
dialog[1] = "in the subway!";
|
||||||
|
dialogLength = 2;
|
||||||
|
pMoney = round(pMoney / 3.0) * 2;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 11: {
|
||||||
|
if (playerDrugInventoryCount() >= 50) {
|
||||||
|
const int pigs = eventId == 9 ? 1 : eventId == 10 ? 3 : 4;
|
||||||
|
dialog[0] = "Officer Hardass and";
|
||||||
|
dialog[1] = String(pigs);
|
||||||
|
dialog[1] += F(" of his deputies");
|
||||||
|
dialog[2] = "are after you!";
|
||||||
|
dialogLength = 3;
|
||||||
|
sPreviousGameState = STATE_FIGHT_MENU;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
} else {
|
||||||
|
sGameState = STATE_TURN_MENU;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 12:
|
||||||
|
case 13: {
|
||||||
|
if (pMoney >= 500 && playerCapacityRemaining() >= 5) {
|
||||||
|
const int x = random(3);
|
||||||
|
dialog[0] = "Will you buy a";
|
||||||
|
if (x == 0 || x == 1) {
|
||||||
|
dialog[1] = x == 0 ? "baretta for" : ".44 magnum for";
|
||||||
|
dialog[2] = "400 dollars?";
|
||||||
|
dialogLength = 3;
|
||||||
|
} else {
|
||||||
|
dialog[1] = "saturday night";
|
||||||
|
dialog[2] = "special for 400";
|
||||||
|
dialog[3] = "dollars?";
|
||||||
|
dialogLength = 4;
|
||||||
|
}
|
||||||
|
sGameState = STATE_BUY_GUN_DIALOG;
|
||||||
|
} else {
|
||||||
|
sGameState = STATE_TURN_MENU;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 14:
|
||||||
|
dialog[0] = "There's some weed";
|
||||||
|
dialog[1] = "here that smells";
|
||||||
|
dialog[2] = "like good stuff!!";
|
||||||
|
dialog[3] = "Will you smoke it?";
|
||||||
|
dialogLength = 4;
|
||||||
|
sGameState = STATE_DO_WEED_DIALOG;
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
if (pMoney >= 300) {
|
||||||
|
dialog[0] = "Will you buy a new";
|
||||||
|
dialog[1] = "trenchcoat with";
|
||||||
|
dialog[2] = "more pockets for";
|
||||||
|
dialog[3] = "200 bucks?";
|
||||||
|
dialogLength = 4;
|
||||||
|
sGameState = STATE_BUY_COAT_DIALOG;
|
||||||
|
} else {
|
||||||
|
sGameState = STATE_TURN_MENU;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 16: {
|
||||||
|
if (playerCapacityRemaining() >= 8) {
|
||||||
|
const int amount = random(7) + 1;
|
||||||
|
const int drug = random(6);
|
||||||
|
pInventory[drug] += amount;
|
||||||
|
dialog[0] = F("You found ");
|
||||||
|
dialog[0] += String(amount);
|
||||||
|
dialog[1] = F("units of: ");
|
||||||
|
dialog[1] += lookupDrug(drug);
|
||||||
|
dialog[2] = "on a dead dude in";
|
||||||
|
dialog[3] = "the subway!!!";
|
||||||
|
dialogLength = 4;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
} else {
|
||||||
|
sGameState = STATE_TURN_MENU;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 17:
|
||||||
|
dialog[0] = "The market has";
|
||||||
|
dialog[1] = "been flooded with";
|
||||||
|
dialog[2] = "cheap homemade";
|
||||||
|
dialog[3] = "acid!!!!";
|
||||||
|
dialogLength = 4;
|
||||||
|
sDrugPrices[DRUG_ACID] = random(551) + 250;
|
||||||
|
sGameState = STATE_INFO_DIALOG;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sGameState = STATE_TURN_MENU;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void handleMenuAction() {
|
void handleMenuAction() {
|
||||||
screenInitialized = false;
|
screenInitialized = false;
|
||||||
switch (sGameState) {
|
switch (sGameState) {
|
||||||
|
@ -77,6 +221,9 @@ void handleMenuAction() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_JET_MENU:
|
case STATE_JET_MENU:
|
||||||
|
incrementDay();
|
||||||
|
pLocation = menuSelected < pLocation ? menuSelected : menuSelected + 1;
|
||||||
|
newDayRandomEvent();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_BUY_MENU: {
|
case STATE_BUY_MENU: {
|
||||||
|
@ -98,7 +245,8 @@ void handleMenuAction() {
|
||||||
dialog[0] = F("Oops!");
|
dialog[0] = F("Oops!");
|
||||||
dialog[1] = F("");
|
dialog[1] = F("");
|
||||||
dialog[2] = F("You can't afford");
|
dialog[2] = F("You can't afford");
|
||||||
dialog[3] = lookupDrug(sCurrentDrug) + F("!");
|
dialog[3] = lookupDrug(sCurrentDrug);
|
||||||
|
dialog[3] += F("!");
|
||||||
dialogLength = 4;
|
dialogLength = 4;
|
||||||
dialogSmall = false;
|
dialogSmall = false;
|
||||||
sPreviousGameState = sGameState;
|
sPreviousGameState = sGameState;
|
||||||
|
@ -123,7 +271,8 @@ void handleMenuAction() {
|
||||||
dialog[0] = F("Oops!");
|
dialog[0] = F("Oops!");
|
||||||
dialog[1] = F("");
|
dialog[1] = F("");
|
||||||
dialog[2] = F("You don't have any");
|
dialog[2] = F("You don't have any");
|
||||||
dialog[3] = lookupDrug(sCurrentDrug) + F("!");
|
dialog[3] = lookupDrug(sCurrentDrug);
|
||||||
|
dialog[3] += F("!");
|
||||||
dialogLength = 4;
|
dialogLength = 4;
|
||||||
dialogSmall = false;
|
dialogSmall = false;
|
||||||
sPreviousGameState = sGameState;
|
sPreviousGameState = sGameState;
|
||||||
|
@ -156,6 +305,7 @@ void handleMenuAction() {
|
||||||
break;
|
break;
|
||||||
case STATE_BANK_MENU:
|
case STATE_BANK_MENU:
|
||||||
sPreviousGameState = STATE_BANK_MENU;
|
sPreviousGameState = STATE_BANK_MENU;
|
||||||
|
sCurrentQty = 0;
|
||||||
switch (menuSelected) {
|
switch (menuSelected) {
|
||||||
case 0: // deposit money
|
case 0: // deposit money
|
||||||
sGameState = STATE_DEPOSIT_INPUT;
|
sGameState = STATE_DEPOSIT_INPUT;
|
||||||
|
@ -185,5 +335,14 @@ int playerCapacityRemaining() {
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
qty += pInventory[i];
|
qty += pInventory[i];
|
||||||
}
|
}
|
||||||
|
qty += pGuns * 5;
|
||||||
return pCapacity - qty;
|
return pCapacity - qty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int playerDrugInventoryCount() {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
count += pInventory[i];
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue