Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Chocobois/built-to-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
Golen87 committed Aug 19, 2024
2 parents 259bd2a + 038ea51 commit 3f4119e
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 28 deletions.
5 changes: 5 additions & 0 deletions src/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ const audios: Audio[] = [
sound('goldbath', 'goldbath', 0.5),
sound('fail', 'rip', 0.5),
sound('sqk', 'sqk', 0.5),
sound('endday', 'endday', 0.5),
sound('chomp', 'chomp', 0.5),
sound('bite', 'bite', 0.5),
sound('doink', 'doink', 0.5),
sound('slurp', 'slurp', 0.5),
sound('tree/meme_explosion_sound', 'meme_explosion_sound', 0.5),
];

Expand Down
Binary file modified src/assets/images/items/checkout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/wax1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/wax2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/images/items/wax3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/sounds/bite.mp3
Binary file not shown.
Binary file added src/assets/sounds/chomp.mp3
Binary file not shown.
Binary file added src/assets/sounds/doink.mp3
Binary file not shown.
Binary file added src/assets/sounds/endday.mp3
Binary file not shown.
Binary file added src/assets/sounds/slurp.mp3
Binary file not shown.
58 changes: 57 additions & 1 deletion src/components/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class Customer extends Button {
public maxPatience: number = 1; // bonuses
public lockPatience: boolean; // bonuses

public actionsComplete: boolean = false;

// Stats
public doingCuteThing: boolean;
public tasksCompleted: number;
Expand All @@ -64,8 +66,14 @@ export class Customer extends Button {
private angryImage: Phaser.GameObjects.Image;
private patienceTimer: Timer;

public itemList: number[];
public sprList: Phaser.GameObjects.Sprite[];

private testTimer:PatienceTimer;

private eatDelay: number = 0;
private playFail: boolean = false;

//testing stuff
constructor(
scene: GameScene,
Expand Down Expand Up @@ -129,6 +137,9 @@ export class Customer extends Button {
this.patienceTimer.setAlpha(0);
this.add(this.patienceTimer);

this.itemList = [];
this.sprList = [];

this.bindInteractive(this.sprite, true);
}

Expand All @@ -144,6 +155,7 @@ export class Customer extends Button {
interpolateColor(0xffffff, 0xff0000, 1 - this.happiness)
);


if (this.isWaiting) {
this.patienceTimer.setVisible(true);
if (!this.dragged) {
Expand Down Expand Up @@ -177,10 +189,33 @@ export class Customer extends Button {
this.emit("angry");
}
} else {
this.testTimer.update(time,delta);
this.patienceTimer.setVisible(false);
this.angryImage.setVisible(false);
}

this.testTimer.update(time,delta);
if(this.itemList.length > 0){
if(this.eatDelay <= 0) {
this.eatDelay = 100+Math.random()*200;
}
}
if(this.eatDelay > 0){
this.eatDelay -= delta;
if(this.eatDelay <= 0) {
this.eatDelay = 0;
if(this.itemList.length > 0) {
this.scene.parseCustomerItems(this.itemList.shift()!,this);
if(this.sprList[0]){
this.sprList[0].destroy();
this.sprList.shift();
}
}
}
}
if(this.playFail){
this.scene.sound.play("rip");
this.playFail = false;
}
}

onOver( pointer: Phaser.Input.Pointer,
Expand Down Expand Up @@ -296,6 +331,7 @@ export class Customer extends Button {
this.hasCompleted = true;
this.setRequest(StationType.CashRegister);
} else {
this.actionsComplete = true;
this.parseMoney();
this.scene.sound.play("cashmoney");
this.scene.addEffect(
Expand Down Expand Up @@ -486,6 +522,26 @@ export class Customer extends Button {
this.tips = Math.trunc(this.tips);
}

applyItem(i: number, s: string){
this.itemList.push(i);
let st = new Phaser.GameObjects.Sprite(
this.scene,
-80 + 40 * this.itemList.length,
60,
s
);
st.setOrigin(0.5, 0.5);
st.setScale(0.4);
st.setDepth(4);
st.setAlpha(0.85);
this.add(st);
this.sprList.push(st);
}

queueFail(){
this.playFail = true;
}

parseMoney() {
this.parseHappiness();
}
Expand Down
51 changes: 34 additions & 17 deletions src/components/Inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { GameScene } from "@/scenes/GameScene";
import { Item } from "./Item";
import { SimpleButton } from "./elements/SimpleButton";
import { ItemButton } from "./ItemButton";
import { SnapType } from "./Item";

export class Inventory extends Phaser.GameObjects.Container {
public scene: GameScene;
Expand All @@ -25,19 +26,19 @@ export class Inventory extends Phaser.GameObjects.Container {
super(scene,x,y);
this.scene=scene;
this.itemList = [
new Item(0,"rock",stock[0],1,["rock","cheap"],["cheap"],"Complimentary Pet Rock","A loving pet rock to cheer up any customer. Works modestly well."),
new Item(1,"coke",stock[1],50,["drug"],["illegal","cool"],"Cocaine","A delicious white powder made from plants. Improves working speed a whole bunch!"),
new Item(2,"hotdog",stock[2],25,["raptor","meat","bread","skeleton","ketchup","mustard","gay"],["meat","elitist","gay","gluten"],"Hot Dog","A big wiener with sauce, to satisfy any meat lover. You can also buy a bacon-wrapped cheesy version for 69 kr."),
new Item(3,"brocc",stock[3],12,["triceratops","veggie","healthy","stinky"],["veggie","healthy","stinky"],"Broccoli","This large stalk of free-range broccoli is perfect for vegans and herbivorous animals."),
new Item(4,"usb",stock[4],30,["protogen","tech","metal","nerd"],["nerd","tech"],"Mini USB Drive", "Additional storage space in a compact unit. I wonder who would want this?"),
new Item(5,"milk",stock[5],40,["dragon","horny","creamy","lactose","gay"],["horny","creamy","lactose","gay"],"Fresh Milk","Fresh, creamy milk for dragons. Still warm and thick."),
new Item(6,"snowglobe",stock[6],35,["lugia","kitsch","cold","ball"],["kitsch","cold","ball"],"Snowglobe","A cute little snowglobe. A certain type of customer might want this."),
new Item(7,"pocky",stock[7],30,["boykisser","weeb","cringe","sweet","chocolate"],["weeb","cringe","sweet"],"P*cky","Sweet snack made of edible sticks. There's a traditional game where you kiss while biting them. A favorite of virgins."),
new Item(8,"hourglass",stock[8],110,["time","physics","glass"],["physics"],"Hourglass","Turns back the time on a customer's patience. Might make it hard to work though..."),
new Item(9,"hypnosis",stock[9],90,["hypno","horny","kinky","weird","psychic"],["horny","kinky","weird"],"Hypnosis","Uses a state of hypnosis to keep a customer's patience constant. You can't increase it any more either though."),
new Item(10,"polish",stock[10],80,["expensive","creamy","musky"],["expensive","musky"],"Extra-Premium Polish","Gives scales a wonderful gloss and unique scent. Most customers love it, but comes at a premium."),
new Item(11,"pillowtalk",stock[11],50,["horny","soft","cringe"],["horny","cringe"],"Pillow Talk","Talk to a customer alluringly to have them use more services. Good telemarketing is vital!"),
new Item(12,"shuriken",stock[12],75,["sharp","weeb","ninja","cringe","cool"],["cool","cringe","weeb","sharp"],"Shuriken","Some type of fidget spinner that sharpens mental capabilites. Allows a worker to critical manicure."),
new Item(0,"rock",stock[0],1,["rock","cheap"],["cheap"],"Complimentary Pet Rock","A loving pet rock to cheer up any customer. Works modestly well.", SnapType.CUSTOMER, "doink"),
new Item(1,"coke",stock[1],50,["drug"],["illegal","cool"],"Sugar","A delicious white powder made from plants. Improves working speed a whole bunch!", SnapType.STATION, "chomp"),
new Item(2,"hotdog",stock[2],25,["raptor","meat","bread","skeleton","ketchup","mustard","gay"],["meat","elitist","gay","gluten"],"Hot Dog","A big wiener with sauce, to satisfy any meat lover. You can also buy a bacon-wrapped cheesy version for 69 kr.", SnapType.CUSTOMER, "chomp"),
new Item(3,"brocc",stock[3],12,["triceratops","veggie","healthy","stinky"],["veggie","healthy","stinky"],"Broccoli","This large stalk of free-range broccoli is perfect for vegans and herbivorous animals.", SnapType.CUSTOMER, "chomp"),
new Item(4,"usb",stock[4],30,["protogen","tech","metal","nerd"],["nerd","tech"],"Mini USB Drive", "Additional storage space in a compact unit. I wonder who would want this?", SnapType.CUSTOMER, "doink"),
new Item(5,"milk",stock[5],40,["dragon","horny","creamy","lactose","gay"],["horny","creamy","lactose","gay"],"Fresh Milk","Fresh, creamy milk for dragons to grow strong bones. Still warm and thick.", SnapType.CUSTOMER, "slurp"),
new Item(6,"snowglobe",stock[6],35,["lugia","kitsch","cold","ball"],["kitsch","cold","ball"],"Snowglobe","A cute little snowglobe. A certain type of customer might want this.", SnapType.CUSTOMER, "doink"),
new Item(7,"pocky",stock[7],30,["boykisser","weeb","cringe","sweet","chocolate"],["weeb","cringe","sweet"],"P*cky","Sweet snack made of edible sticks. There's a traditional game where you kiss while biting them. A favorite of virgins.", SnapType.CUSTOMER, "chomp"),
new Item(8,"hourglass",stock[8],110,["time","physics","glass"],["physics"],"Hourglass","Place on a workstation to fully turn back the time on a customer's patience. Might make it hard to work though...", SnapType.STATION, "doink"),
new Item(9,"hypnosis",stock[9],90,["hypno","horny","kinky","weird","psychic"],["horny","kinky","weird"],"Hypnosis","Uses a state of hypnosis to keep a customer's patience constant. You can't increase it any more either though.", SnapType.CUSTOMER, "doink"),
new Item(10,"polish",stock[10],80,["expensive","creamy","musky"],["expensive","musky"],"Extra-Premium Polish","Put this on a station to give scales a wonderful gloss and unique scent. Most customers love it, but comes at a premium.", SnapType.STATION, "slurp"),
new Item(11,"pillowtalk",stock[11],50,["horny","soft","cringe"],["horny","cringe"],"Pillow Talk","Instruct a station to talk to a customer alluringly and have them use more services. Good telemarketing is vital!", SnapType.STATION, "slurp"),
new Item(12,"shuriken",stock[12],75,["sharp","weeb","ninja","cringe","cool"],["cool","cringe","weeb","sharp"],"Shuriken","Equip a station to allow the stylists to critically strike when grooming! It's some type of mysterious fidget spinner that sharpens mental capabilites. ", SnapType.STATION, "meme_explosion_sound"),
];
this.display = [];
this.window = new Phaser.GameObjects.Image(this.scene,x,y,"invwindow");
Expand Down Expand Up @@ -92,14 +93,14 @@ export class Inventory extends Phaser.GameObjects.Container {
let rs = 0;
for(let np = this.currentIndices[0]; np < this.currentIndices[1]+1; np++){
if(np < this.itemList.length){
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, this.itemList[np].id, rs, this.itemList[np].spr));
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, this.itemList[np].id, rs, this.itemList[np].spr, this.itemList[np].snap));
if(this.itemList[np].quant <= 0) {
this.display[rs].shadow();
}
this.add(this.display[rs]);
}
else {
this.display[rs] = new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, -1, rs, "blankspr");
this.display[rs] = new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, -1, rs, "blankspr", SnapType.STATION);
this.add(this.display[rs]);
}
rs++;
Expand All @@ -112,14 +113,14 @@ export class Inventory extends Phaser.GameObjects.Container {
this.display = [];
for(let np = this.currentIndices[0]; np < this.currentIndices[1]+1; np++){
if(np < this.itemList.length){
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, this.itemList[np].id, rs, this.itemList[np].spr));
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, this.itemList[np].id, rs, this.itemList[np].spr, this.itemList[np].snap));
if(this.itemList[np].quant <= 0) {
this.display[rs].shadow();
}
this.add(this.display[rs]);
}
else {
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, -1, rs, "blankspr"));
this.display.push(new ItemButton(this.scene,this.coordinates[rs][0], this.coordinates[rs][1], this, -1, rs, "blankspr", SnapType.STATION));
this.add(this.display[rs]);
}
rs++;
Expand Down Expand Up @@ -178,6 +179,22 @@ export class Inventory extends Phaser.GameObjects.Container {
}
}

glassify(){
this.window.setAlpha(0.17);
this.title.setAlpha(0.2);
this.tdisplay.setAlpha(0.2);
this.fwButton.setAlpha(0.2);
this.display.forEach((sp) => sp.setAlpha(0.2));
}

unglassify(){
this.window.setAlpha(0.85);
this.title.setAlpha(1);
this.tdisplay.setAlpha(1);
this.fwButton.setAlpha(1);
this.display.forEach((sp) => sp.setAlpha(1));
}

scroll(){
if(this.currentIndices[1] < this.itemList.length) {
let b = this.currentIndices[1] + 1;
Expand Down
14 changes: 13 additions & 1 deletion src/components/Item.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export enum SnapType {
CUSTOMER,
STATION,
}

export class Item {
public id:number;
public spr:string;
Expand All @@ -7,6 +12,10 @@ export class Item {
public antitags:string[];
public name:string;
public desc:string;
public snap:SnapType;
public sound: string;

public clippingType: number;

//-1 - default item, does nothing
//0 - Complimentary Pet Rock - increases satisfaction by one stage
Expand All @@ -23,7 +32,7 @@ export class Item {
//11 - pillow talk - adds a random station to the end of a customer's itinerary
//12 - shuriken - barbers can crit, crit causes happiness to raise one stage

constructor(id:number,sp:string,qt:number,pr:number,tgs:string[],atgs:string[],name:string,dsc:string) {
constructor(id:number,sp:string,qt:number,pr:number,tgs:string[],atgs:string[],name:string,dsc:string,snptype: SnapType, sound: string) {
this.id=id;
this.spr=sp;
this.quant=qt;
Expand All @@ -32,6 +41,9 @@ export class Item {
this.antitags=atgs;
this.name=name;
this.desc=dsc;
this.snap = snptype;
this.sound = sound;

}

setQuantity(n:number){
Expand Down
10 changes: 7 additions & 3 deletions src/components/ItemButton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Item } from "./Item";
import { Item, SnapType } from "./Item";
import { Inventory } from "./Inventory";
import { Button } from "./elements/Button";
import { BaseScene } from "@/scenes/BaseScene";
Expand All @@ -15,13 +15,15 @@ export class ItemButton extends Button {
public dragY: number;
public doingCuteThing: boolean;
private parent: Inventory;
constructor(scene:BaseScene,x:number,y:number,parent: Inventory, id:number, index:number, spr:string){
public snap: SnapType;
constructor(scene:BaseScene,x:number,y:number,parent: Inventory, id:number, index:number, spr:string, snp: SnapType){
super(scene,x,y);
this.parent = parent;
this.default = [x,y];
this.id=id;
this.index=index;
this.sprname = spr;
this.snap = snp;
this.spr = new Phaser.GameObjects.Sprite(this.scene,x,y,spr,0);
this.spr.setOrigin(0.5,0.5);
this.bindInteractive(this.spr, true);
Expand Down Expand Up @@ -84,6 +86,7 @@ export class ItemButton extends Button {
this.state = 3;
this.parent.remove(this);
this.parent.scene.setActiveItem(this);
this.parent.scene.veilInvButton();
this.setPosition(0,0);
this.split();
this.passivate = true;
Expand Down Expand Up @@ -139,7 +142,7 @@ export class ItemButton extends Button {
}

split(){
this.parent.display[this.index] = new ItemButton(this.scene,this.default[0],this.default[1],this.parent,this.id,this.index,this.sprname);
this.parent.display[this.index] = new ItemButton(this.scene,this.default[0],this.default[1],this.parent,this.id,this.index,this.sprname,this.snap);
this.parent.itemList[this.id].quant--;
let r = this.parent.itemList[this.id].quant;
if(r <= 0) {
Expand All @@ -148,6 +151,7 @@ export class ItemButton extends Button {
this.parent.display[this.index].select();
}
this.parent.updateAmountText(this.id,r);
this.parent.glassify();
}

}
69 changes: 69 additions & 0 deletions src/components/ItemHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,41 @@ export class ItemHandler {
}
}


processCustomerItem(i: Item, ct: Customer){
switch(i.id)
{
case -1: {
break;
} case 0: {
ct.rockBonus = 1;
break;
} case 2: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 3: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 4: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 5: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 6: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 7: {
this.parseCustomerPreferredItem(i,ct);
break;
} case 9: {
ct.lockPatience = true;
break;
}
break;
}
}

parsePreferredItem(i: Item, st:Station, ct:Customer){
let state = 0;
if((i.tags.length > 0) && (ct.tags.length > 0)) {
Expand Down Expand Up @@ -123,4 +158,38 @@ export class ItemHandler {
return;
}
}

parseCustomerPreferredItem(i: Item, ct:Customer){
let state = 0;
if((i.tags.length > 0) && (ct.tags.length > 0)) {
for(let nt = 0; nt < i.tags.length; nt++){
if(ct.tags.includes(i.tags[nt])) {
state = 1;
}
}
}

if((i.antitags.length > 0) && ct.antitags.length > 0){
for(let na = 0; na < i.antitags.length; na++){
if(ct.antitags.includes(i.tags[na])) {
state = -1;
}
}
}

if(state == 1) {
ct.happinessBonus += 2;
ct.tipBonus+=0.25;
return;
} else if (state == -1) {
ct.happinessBonus -= 2.125;
ct.maxHappiness = 4.01;
ct.tipMultiplier*=0.25;
//ct.queueFail = true;
return;
} else {
ct.happinessBonus += 0.5;
return;
}
}
}
Loading

0 comments on commit 3f4119e

Please sign in to comment.