-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlyby.go
1027 lines (985 loc) · 28.1 KB
/
Flyby.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package main
import ("fmt"; "time"; "math/rand"; "os"; "os/exec"; "syscall"; "unsafe"; "strconv"; "unicode"; "strings"; "bufio")
//need to add a hellcase mode
var (
//ints
lines int // Tracks how many terminal lines are written
cash int // Starting money and balance (Set in main())
wins int // How many wins (unused)
losses int // How many losses (unused)
bet int // User submitted bet amount
bets int // How many bets the player made
last int // Stores how many letters were written by progWrite
score int // Most money the player had at peak
frames int // How long the rolling animation wil be
rate int // Animation roll delay in miliseconds
arrSize = 64 // Number of cells in the rolling array
winStreak int // Count how many wins in a row
jam int // number to jam the machine on
achievements int // how many achievements you have
perceptive int // The number forseen by the "Perception" ticker mode
startingCash = 100 // How much the player starts with
rehabVisits int // Count rehab visits
beers int // Count how many beers you drank
weeds int // Count how many joints were smoked
intoxication int // How drunk the player is. 10 beers = 50/50 chance of death
lastBet int // Store the last bet so you can bet again with "last"
//bools
celebrateMil = true // Celebrate breaking over one million
celebrate1k = true // Celebrate breaking a thousand
celebrate1hk = true // Celebrate breaking a hundred thousand
ach69 = false // has the player gotten acheivements for 69, 404, etc
ach404 = false
ach420 = false
ach808 = false
ach1337 = false
jamming = true //Enable or disable jamming
jammed = false // This is set if the machine jams
rigged = false // ALWAYS lose, right next to a 9
winner = false // ALWAYS roll 9
bartenderDead = false
drugdealerDead = false
ownerDead = false
//strings
tickerMode = "None" //Option for how the ticker behaves. Options are None, Perception and Ticker
gameMode = "Sandbox" // Sandbox, Hellcase, Challenge
spinMode = "None" // How spinning works. "Fast" and "None". "Fast" means no slowdown
entry = "" // variable for user input. Gets checked, then converted to an int.
//arrays
arrSlice = make([]int, arrSize) // Where the rolling numbers are stored
//reader?
reader = bufio.NewReader(os.Stdin)
//ANSI colors set to strings. Print any of these strings to color the terminal
Reset = "\033[0m" //sets color to default again.
Red = "\033[31m"
Green = "\033[32m"
Yellow = "\033[33m"
Blue = "\033[34m"
Magenta = "\033[35m"
Cyan = "\033[36m"
Gray = "\033[90m"
BRed = "\033[91m"
BGreen = "\033[92m"
BYellow = "\033[93m"
BBlue = "\033[94m"
BMagenta= "\033[95m"
BCyan = "\033[96m"
White = "\033[97m"
Black = "\033[30m"
colorMap = map[int]string{ // set the color of each number
0: Black,
1: White, //1 can never occur, but if it did
2: White,
3: Cyan,
4: BBlue,
5: BCyan,
6: BMagenta,
7: BGreen,
8: BRed,
9: BYellow,
}
)
func clean(x int) { //where "X" is the number of lines you want to clean
fmt.Print("\x1b[",x,"A\x1b[J")
lines = lines - x
if (lines < 0) {
lines = 0
}
}
func progWrite(s string, delayMS int) { //write the given string out one letter at a time
last = 0 // reset count each time prog write is called
for _, letter := range s {
fmt.Printf("%c", letter)
last++ //call "last" in progDel to erase these lines
time.Sleep(time.Duration(delayMS) * time.Millisecond)
}
}
func progDel(rm int, dly int) { //won't work across lines
i := 0 // the := tells the compiler "figure this variable out"
for i < rm {
fmt.Printf("\b \b") // backspace. needs two to delete the pointer letter
i++
last--
time.Sleep(time.Duration(dly) * time.Millisecond)
}
}
func main() {
// intro movie
// maybe add a check for terminal size here?
//begin startup checks
startupChecks()
//end startup checks
setRawMode() // disable keyboard inputs
cash = startingCash
score = cash
winStreak = 0 // could move this to a "resetParams" function
color(Reset)
seedRNG()
progWrite("---FLYBY------V------------------------------------------------\n", 50)
introText()
progWrite("--------------^------------------------------------------------\n", 25)
fmt.Print(" / \\", "\n") // two backslashes to show it's not an operator
fmt.Print("Cash: $", cash)
lines += 4
funcBet()
}
func funcBet() {
fmt.Print("\n") // balance is printed in this new line
fmt.Print("Place your bet: "); lines += 1
resetMode()// allow keyboard input.
//fmt.Scan(&entry) // this is old and doesn't work the best.
entry, _ := reader.ReadString('\n')
lcentry := strings.ToLower(strings.TrimSpace(entry)) //might add strings.ReplaceAll(entry, " ", "")
setRawMode()// go back to disabled inputs
//process as string first
quitAction := []string{"quit", "leave", "walk away", "exit", "win", "close"}
if contains(quitAction, lcentry) {
if (cash < startingCash) { // if you're below 100 bucks
//write("\n") //not needed
color(BRed)
progWrite("Yeah yeah, ", 50); wait(500); progWrite("just get out of here...", 50)
wait(1000)
write("\n")
quit()
}
if (cash == startingCash && bets == 0) { //if you never bet
neverGamble()
}
quitSeq() //if you left on good terms
}
//smoke weed
weedAction := []string{"weed", "ganja", "herbis", "smoke blunt", "toke up", "smoke weed", "roll joint"}
if contains(weedAction, lcentry) {
if (drugdealerDead == false) {
Reset = Green
color(Reset)
clean(2)
redraw()
fmt.Print("*Puff* Bro, you got like... $", cash, "... man...")
weeds++
funcBet()
}
clean(2)
progWrite("The dealer is dead. ", 50); wait(500); progWrite("No more drugs. ", 50)
wait(1000)
writeCash()
funcBet()
}
//get drunk
drunkAction := []string{"drink", "beer", "liquor", "whiskey", "get drunk", "shots", "take a shot", "get loaded"}
if contains(drunkAction, lcentry) {
if (bartenderDead == false) {
Reset = Yellow
color(Reset)
clean(2)
redraw()
switch intoxication {
case 0:
fmt.Print("Hey bartender! Got anything to drink? Balance $", cash)
case 1:
fmt.Print("Order up! *TSSSSSK* *Clink* *Clink* You have $", cash)
case 2:
fmt.Print("*Bartender rolls a beer to you* *TSSSK* You have $", cash)
case 3:
fmt.Print("Another one! Hit me! *TSSSSK* balance $", cash)
case 4:
fmt.Print("Bartender! Over here! *TSSSSSSSSSK* balance $", cash)
case 5:
fmt.Print("Hey bah, how about another round, wah? balance $", cash)
case 6:
fmt.Print("Yoooooo... bartender! Over here... balance $", cash)
case 7:
fmt.Print("Buddaaaaay, I needs... another... balance $", cash)
case 8:
fmt.Print("*Hiccup* Byyysss gots me... *hiccup* 'bout... $", cash)
case 9:
fmt.Print("Heyyyyy *hiccup* I... uhhh... *snort* got... $", cash)
case 10:
r := rand.Intn(2) // roll 50/50 for death
if (r == 1) { //survive
Reset = "\033[0m"
color(Reset)
redraw()
progWrite("Someone notices your drunkeness and calls an ambulance", 50)
wait(1000)
progDel(last, 20)
fmt.Print("The nurse at rehab said: You have $", cash,"!")
rehabVisits++
intoxication = 0
funcBet()
} // die
progWrite("You have died of alcohol poisoning.", 50)
wait(1000)
fmt.Print("\n")
Reset = "\033[0m"
color(Reset)
progWrite("Onlookers tried to call 911, but it was too late", 50)
wait(1000)
fmt.Print("\n")
progWrite("Highest score: $", 50)
wait(1000)
fmt.Print(cash)
wait(2000)
fmt.Print("\n")
color(BCyan)
progWrite("Thank you for playing!", 50)
wait(1000)
quit()
}
beers++
intoxication++
funcBet()
}
clean(2)
progWrite("The bartender is dead. ", 50); wait(500); progWrite("No more drinks. ", 50)
wait(1000)
//fmt.Print("Cash: $", cash)
writeCash()
funcBet()
}
//get sober
soberAction := []string{"rehab", "sober", "hospital", "sober up", "i have a problem"}
if contains(soberAction, lcentry) {
Reset = "\033[0m"
color(Reset)
clean(2)
redraw()
fmt.Print("The nurse at rehab said: You have $", cash,"!")
rehabVisits++
intoxication = 0
funcBet()
}
// Kill bartender
if (lcentry == "kill bartender" || lcentry == "shoot bartender" || lcentry == "slay bartender") {
if (bartenderDead == false) {
clean(2)
color(Yellow)
progWrite("You pull out your .38 special and shoot the bartender", 50)
wait(800)
progWrite("\nHe cries out: ", 25); wait(500); progWrite("Mother Mary!", 25)
wait(1000)
homeCursor()// i have no idea why this is so fucked.
clean(1)
color(Reset)
bartenderDead=true
fmt.Print("Cash: $", cash)
funcBet()
}
color(Yellow)
progWrite("Bartender is already dead...", 25)
wait(870)
progDel(last, 10)
color(Reset)
clean(2)
writeCash()
funcBet()
}
//Kill drug dealer
killDruggieAction := []string{"kill druggie", "kill drug dealer", "shoot druggie", "shoot drug dealer", "slay dealer"}
if contains(killDruggieAction, lcentry) {
if (drugdealerDead == false) {
clean(2)
color(Green)
progWrite("You walk over with your .38 special and shoot the drug dealer", 50)
wait(800)
progWrite("\nHe cries out: ", 25); wait(500); progWrite("Holy fuck, bah!", 25)
wait(1000)
homeCursor()// i have no idea why this is so fucked.
clean(1)
color(Reset)
drugdealerDead=true
fmt.Print("Cash: $", cash)
funcBet()
}
color(Green)
progWrite("The drug dealer is already dead...", 25)
wait(870)
progDel(last, 10)
color(Reset)
clean(2)
writeCash()
funcBet()
}
if (lcentry == "perception") { // set ticker mode
if (tickerMode == "Perception") {
clean(2)
tickerMode = "None"
writeCash()
fmt.Print(" Perception mode: OFF ")
funcBet()
} else { // else needs to be candy-wrapper form
clean(2)
tickerMode = "Perception"
writeCash()
color(BBlue)
fmt.Print(" Perception mode: ON ")
color(Reset)
funcBet()
}
}
if (lcentry == "fast") { // set fast mode
if (spinMode == "Fast") {
clean(2)
spinMode = "None"
writeCash()
fmt.Print(" Fast spin: OFF ")
funcBet()
} else { // else needs to be candy-wrapper form
clean(2)
spinMode = "Fast"
writeCash()
color(BBlue)
fmt.Print(" Fast spin: ON ")
color(Reset)
funcBet()
}
}
betMaxAction := []string{"everything", "all in", "max", "all", "full"}
if contains(betMaxAction, lcentry) {
bet = cash
if (bet >= 10000) { //Taunt player for betting everything
msgAllIn()
}// roll straight from here
// bets++
// clean(2) // wipe balance and bet lines
// setRawMode() // disable keyboard input
funcRoll(bet)
}
if (lcentry == "half") {
bet = cash / 2
//bets++
//clean(2)
//setRawMode()
funcRoll(bet)
}
if (lcentry == "tenth") {
bet = cash / 10
//bets++
//clean(2) // these lines are redundant. they've been moved to the top of funcRoll
//setRawMode()
funcRoll(bet)
}
if (lcentry == "last" || lcentry == "l") {
bet = lastBet
if (bet > cash) {
clean(2)
fmt.Print("Not enough cash. You have $", cash)
funcBet()
}
//bets++
//clean(2)
//setRawMode()
funcRoll(bet)
}
killSelfAction := []string{"suicide", "kill self", "end life", "commit suicide", "shoot self", "blow brains out"}
if contains(killSelfAction, lcentry) {
killSelf()
}
if (lcentry == "restart") {
restart()
}
if (lcentry == "redraw") {
clean(2)
redraw()
writeCash()
funcBet()
}
// now actually convert
filteredInput := filterDigits(entry)
bet, err := strconv.Atoi(filteredInput) //convert string to int, assign to bet variable
// handle error
if err != nil {
clean(2)
fmt.Print("You ok, man? That didn't make sense. You got $", cash)
funcBet()
}
// post int conversion
if (bet > cash){
clean(2)
fmt.Print("Not enough cash. You have $", cash)
funcBet()
}
switch bet {
case 69:
if (ach69 == false) {
achWrite(BMagenta, "Hehehehehee...", 1000, 100)
ach69 = true
achievements++
}
case 404:
if (ach404 == false) {
achWrite(Cyan, "Bet not found...", 1000, 50)
ach404 = true
achievements++
}
case 420:
if (ach420 == false) {
achWrite(Green, "Green like that", 1000, 70)
ach420 = true
achievements++
}
case 808:
if (ach808 == false) {
achWrite(BYellow, "Drum Machine", 808, 80)
ach808 = true
achievements++
}
case 1337:
if (ach1337 == false) {
achWrite(BGreen, "Gamer!", 1500, 50)
ach1337 = true
achievements++
}
}
if (bet == cash && cash >= 10000) { //Taunt player for betting everything
msgAllIn()
}
if (bet <= 0 && bets == 0) { // congradulate dudes for not gambling
neverGamble()
}
if (bet <= 0) { // Quit sequence
quitSeq()
}
// bets++ // bet succeeded by this point
// clean(2) // wipe balance and bet lines
// setRawMode() // disable keyboard input
// lastBet = bet
funcRoll(bet)
}
func funcRoll(bet int) {
bets++ // bet succeeded by this point
clean(2) // wipe balance and bet lines
setRawMode() // disable keyboard input
lastBet = bet
moveUp(3)
rate = 10 // old value: 8
frameMax := 256
if (jamming == true) { // jamming function.
rand.Seed(time.Now().UnixNano())
r := rand.Intn(4) // r is just a new variable for this RNG
if (r == 1) {
jammed = true
if (bets == 0) {
jam = rand.Intn(frameMax-50) + 50 // makes the first bet actually fair
}
jam = rand.Intn(frameMax)
} else {
jam = frameMax //else, no jamming)
}
}
var result int // set from 0 - 9 depending on number from RNG
for frames := 0; frames < jam; frames++ { // set jam to frameMax if it breaks!
//rand.Seed(time.Now().UnixNano()) //not actually needed it seems
rng := rand.Intn(100)
if (rng <= 60) { result = 0; } // winning / odds table
if (rng >= 61 && rng < 70) { result = 2; }
if (rng >= 70 && rng < 75) { result = 3; }
if (rng >= 75 && rng < 80) { result = 4; }
if (rng >= 80 && rng < 85) { result = 5; }
if (rng >= 85 && rng < 90) { result = 6; }
if (rng >= 90 && rng < 95) { result = 7; }
if (rng >= 95 && rng < 99) { result = 8; }
if (rng >= 99) { result = 9; }
//Rigging. DISABLED IF GLOBAL BOOLS "winner" or "rigged" are distabled!
if (rigged == true && winner == false && frames == 207) { // rigged, place 0
result = 0
}
if (rigged == true && winner == false && frames == 208) { // rigged place nine after 0
result = 9
}
if (winner == true && rigged == false && frames == 207) { //winner, get 9 always
result = 9
}
//End of rigging.
arrSlice = append(arrSlice, result) // stick random number on the end of the slice (array)
arrSlice = arrSlice[1:] //remove first element
slicePrint(arrSlice)
moveDown(2)
//Ticker line switch
switch tickerMode {
case "None":
fmt.Print(" / \\ ", (frames+1), "/", frameMax, " \n")
case "Perception":
if frames == 207 {
perceptive = arrSlice[63]
}
if frames < 207 {
perceptive = 0
}
fmt.Print(" /");fmt.Printf("%s%d%s", colorMap[perceptive], perceptive, Reset); fmt.Print("\\ ",(frames+1), "/", frameMax, " \n") // this line kills me
case "Ticker":
fmt.Print(" /");singleSlice(arrSlice,15);fmt.Print("\\ ", (frames+1), "/", frameMax, " \n")
}
//End ticker line switch
time.Sleep(time.Duration(rate) * time.Millisecond)
if (frames > frameMax/2 && spinMode == "None") { // Slowdown spinning.
rate = rate + 1
}
if (frames < jam - 1) { //replace jam with frameMax if it breaks!
moveUp(3)
}
}
if (jammed == true) {
if (arrSlice[15] > 0) { //flashing colors if you won
flickerLine("JAMMED!", 80, BYellow, BGreen, 10, 500)
}
if (arrSlice[15] == 0) {
flickerLine("JAMMED!", 80, Red, BRed, 10, 500)
}
jammed = false
}
if (arrSlice[15] > 0) {
wins++
winStreak++
cash += (bet*arrSlice[15])
//Celebration messages
if (arrSlice[15] == 9) { // Celebrate hitting a 9
color(BYellow)
progWrite("GOLDEN 9x WIN!", 50)
color(Reset)
wait(800)
progDel(last, 10)
}
if (cash >= 1000000 && celebrateMil == true) { // Celebrate hitting 1 mil
color(BYellow)
progWrite("YEEEEEEEAAAAAAAAAAAAAAH!", 50)
color(Reset)
wait(500)
progDel(last, 10)
color(BGreen)
progWrite("BROKE ONE MILLION!", 50)
color(Reset)
wait(500)
progDel(last, 10)
celebrateMil = false
}
if (cash >= 100000 && celebrate1hk == true) { // Celebrate hitting 100k
color(BGreen)
progWrite("BROKE A HUNDRED THOUSAND!", 50)
color(Reset)
wait(500)
progDel(last, 10)
celebrate1hk = false
}
if (cash >= 1000 && celebrate1k == true) { // Celebrate hitting 1k
fmt.Print(BGreen)
progWrite("BROKE ONE THOUSAND!", 50)
fmt.Print(Reset)
wait(500)
progDel(last, 10)
celebrate1k = false
}
fmt.Print("Cash: $", cash, BGreen, " WON! ",BYellow,"+$", bet*arrSlice[15], Reset)
if (cash > score) {
score = cash
if (winStreak >= 2) {
color(BMagenta)
fmt.Print(" ", winStreak, " WIN STREAK!")
color(Reset)
}
if (cash >= 10000) {
//fmt.Print(BCyan, " NEW HIGHSCORE!",Reset)
color(BCyan) //colors the place bet line too
wait(500)
progWrite(" NEW HIGHSCORE!", 50)
}
}
} else { // lose - array hit zero
cash = cash - bet
losses++
winStreak = 0
fmt.Print("Cash: $", cash, BRed, " LOST -$", bet, Reset)
}
if (cash <= 0 && bets == 1 ) { // lost after one bet
fmt.Print("\n", Red)
wait(1500)
progWrite("Buddy. ", 50)
wait(700)
progWrite("Yer shockin'", 50)
wait(1000)
fmt.Print("\n", Reset)
quit()
}
if (cash <= 0 && score == startingCash && bets > 1 ) { // lost, never got over starting cash
fmt.Print("\n", Red)
wait(1000)
progWrite("Walk on home, boy.", 50)
wait(1000)
fmt.Print("\n", Reset)
quit()
}
if (cash <= 0) { //lose sequence
wait(1500) // suspense delay, lol
fmt.Print("\n")
color(BRed)
progWrite("GAME OVER!\n", 100)
wait(500)
color(Red)
progWrite("You have lost everything\n", 50)
wait(1000)
color(Reset)
progWrite("-------------------------------\n",50)
progWrite("Highest score: $",50)
wait(1000)
fmt.Print(score,"\n")
wait(1000)
progWrite("Bet count: ",20)
wait(1000)
fmt.Print(bets,"\n")
wait(1000)
if (score > 32000) { // Make fun of the player for losing hard
msgTotalLoser()
wait(1000)
fmt.Print("\n")
}
quit()
}
funcBet()
}
func tauntWrite (text string, speed int, wait int) {
// structured as text you want, speed it's written, time until deletion.
progWrite(text, speed)
time.Sleep(time.Duration(wait) * time.Millisecond)
progDel(last, 10)
}
func color (col string) { // short way of coloring terminal. Reset with color(Reset)
fmt.Print(col)
}
func moveUp (amt int) {
fmt.Print("\x1b[",amt,"F")
}
func moveDown (amt int) {
fmt.Print("\x1b[",amt,"E")
}
func homeCursor() {
fmt.Print("\033[1G")
}
func wait (msec int) { //short way to execute time.Sleep in Milliseconds
time.Sleep(time.Duration(msec) * time.Millisecond)
}
func quit() {
resetMode()
os.Exit(0)
}
func startupChecks() {
if (winner == true && rigged == true) {
write("Winner and Rigged are both true.\nDisable one and recompile")
quit()
}
}
func restart() { // restart the game
clean(6)
Reset = "\033[0m"
bets = 0
achievements = 0
celebrateMil = true // Celebrate breaking over one million
celebrate1k = true // Celebrate breaking a thousand
celebrate1hk = true // Celebrate breaking a hundred thousand
ach69 = false // has the player gotten acheivements for 69, 404, etc
ach404 = false
ach420 = false
ach808 = false
ach1337 = false
drugdealerDead = false
bartenderDead = false
intoxication = 0
beers = 0
weeds = 0
rehabVisits = 0
lastBet = 0
main()
}
func write (text string) { //do I hate writing fmt.Println()? Yes.
fmt.Println(text)
}
func writeCash() {
fmt.Print("Cash: $", cash)
}
func charCount(str string) int {
return len(str)
}
func contains(slice []string, item string) bool { //check if entry is equal to an array element
for _, v := range slice {
if strings.EqualFold(v, item) {
return true
}
}
return false
}
func flickerLine(text string, speed int, color1 string, color2 string, times int, displayTime int) {
// text is what's written, speed is how fast it flickers, color 1 and 2 will alternate, times is how many flickers
for i := 0; i <= times ; i++ {
homeCursor() // make sure she's home
color(color1) //set text to color 1
fmt.Print(text) // write it out
wait(speed) // wait a bit
homeCursor() // back to the start of the line
color(color2) // change color
fmt.Print(text) //reprint text in new color
wait(speed) // wait some more
}
wait(displayTime) // how long the message stays on the last color
letters := charCount(text) // get letters amount from the input string
progDel(letters, 50) // remove them at usual speed
color(Reset) // reset color
//done
}
func achWrite (colour string, achievement string, stop int, speed int) {
//Structured as color you want, achievement text, pause time, speet it's written
color(colour)
progWrite("Achievement unlocked: ", 50)
wait(stop)
progWrite(achievement, speed)
wait(1500)
progDel(last, 50)
progDel(22, 50) // remove "Achievement Unlocked: " text
color(Reset)// not needed, good to have
}
func singleSlice (slice []int, pos int) { //name the slice, name the position
fmt.Printf("%s%d%s", colorMap[slice[pos]], slice[pos], Reset)
}
func seedRNG() {
rand.Seed(time.Now().UnixNano())
}
func slicePrint (slice []int) { //prints a slice without commas, spaces or []
for i := 1; i < len(slice); i++ {
fmt.Printf("%s%d%s", colorMap[slice[i]], slice[i], Reset)
}
}
func setRawMode() { //thanks copilot
termios := &syscall.Termios{}
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(syscall.Stdin), uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(termios)), 0, 0, 0)
termios.Lflag &^= syscall.ICANON | syscall.ECHO
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(syscall.Stdin), uintptr(syscall.TCSETS), uintptr(unsafe.Pointer(termios)), 0, 0, 0)
}
func resetMode() { // thanks copilot
cmd := exec.Command("stty", "-F", "/dev/tty", "sane")
cmd.Stdout = os.Stdout
cmd.Run()
}
func filterDigits(input string) string { //isolate numbrs from strings
result := ""
for _, char := range input {
if unicode.IsDigit(char) {
result += string(char)
}
}
return result
}
func removeSpaces(input string) string { //unused, maybe useful
var result strings.Builder
for _, char := range input {
if !unicode.IsSpace(char) {
result.WriteRune(char)
}
}
return result.String()
}
func quitSeq() {
color(BGreen)
progWrite("You decided to quit!", 50)
wait(2000)
fmt.Println(BYellow,"\n--------------------------------------", Reset)
wait(1000)
fmt.Println("Final balance ",BYellow, "$",cash, Reset)
wait(1000)
fmt.Println("Highest score ",BGreen,"$",score, Reset)
wait(1000)
if (achievements > 0) { // print achievement count.
color(BMagenta)
fmt.Print("Achievements ")
wait(700)
fmt.Print(achievements)
wait(1000)
fmt.Print(Reset, "\n")
}
if (beers > 0) {
color(Yellow)
fmt.Print("Beers Drank ")
wait(500)
color(BRed)
fmt.Print(beers)
wait(1000)
fmt.Print(Reset, "\n")
}
if (weeds > 0) {
color(Green)
fmt.Print("Weeds smoked ")
wait(500)
color(BRed)
fmt.Print(weeds)
wait(1000)
fmt.Print(Reset, "\n")
}
if (rehabVisits > 0) {
color(Cyan)
fmt.Print("Rehab visits ")
wait(700)
fmt.Print(rehabVisits)
wait(1000)
fmt.Print(Reset, "\n")
}
if (bartenderDead == true) {
color(Yellow)
fmt.Print("Bartender ")
wait(700)
color(BRed)
fmt.Print("DEAD!")
wait(1000)
fmt.Print(Reset, "\n")
}
if (drugdealerDead == true) {
color(Green)
fmt.Print("Drug dealer ")
wait(700)
color(BRed)
fmt.Print("DEAD!")
wait(1000)
fmt.Print(Reset, "\n")
}
fmt.Println("Bet count ",bets)
wait(1000)
fmt.Println("Win/loss ",wins,"/",losses)
wait(2000)
color(BCyan)
progWrite("Thank you for playing!",50)
color(Reset)
wait(1000)
fmt.Print("\n")
quit()
}
func killSelf() {
write("\n")
color(Reset)
write("*BOOM*\n")
wait(1500)
progWrite("You splatter your brains all over the casino. ", 50)
wait(1000)
progWrite("\nThe room goes silent. ", 50)
wait(1000)
progWrite("\nHorrified onlookers gasp at the sight of your corpse. ", 50)
wait(1000)
if (bartenderDead == false) {
progWrite("\nThe bartender walks over and says: ", 50); wait(1500)
color(Yellow)
progWrite("Go way witcha'", 50); wait(3000)
color(BBlue)
progWrite("\nThank you for playing.", 50)
wait(1000)
write("\n")
quit()
}
if (drugdealerDead == false && weeds > 0) {
progWrite("\nThe drug dealer walks over and says: ", 50); wait(1500)
color(Green)
progWrite("I'm fokn' deadly sorry, bah...", 50); wait(3000)
color(BBlue)
progWrite("\nThank you for playing.", 50)
wait(1000)
write("\n")
quit()
}
wait(2000)
progWrite("\nThank you for playing.", 50)
wait(1000)
write("\n")
quit()
}
func neverGamble() {
color(BCyan)
progWrite("You'll never lose", 50)
wait(1000)
progWrite(" if you don't play.", 50)
wait(2000)
color(Reset)
quit()
}
func redraw(){ //redraws machine.
moveUp(4)
fmt.Print("---FLYBY------V------------------------------------------------\n")
moveDown(1)
fmt.Print("--------------^------------------------------------------------\n")
fmt.Print(" / \\ \n")
}
func introText() {
sw := rand.Intn(11) // RNG to pick a quote. Value stored in "sw" variable
color(BRed)
switch sw {
case 0:
progWrite(" BET YOUR MAX \n", 200)
case 1:
progWrite(" DO YOUR WORST \n", 200)
case 2:
progWrite(" TIME HEALS NOTHING \n", 200)
case 3:
progWrite(" IT'S ALL OVER \n", 200)
case 4:
progWrite(" MONEY FOR NOTHING \n", 200)
case 5:
progWrite(" WHO LAUGHS LAST? \n", 200)
case 6:
progWrite(" BACK SO SOON? \n", 200)
case 7:
progWrite(" GREED LOSS DEATH \n", 200)
case 8:
progWrite(" HOUSE ALWAYS WINS \n", 200)
case 9:
progWrite(" GREAT DEBT AWAITS \n", 200)
case 10:
progWrite(" TO YOUR GRAVE! \n", 200)
}
color(Reset)
}
func msgTotalLoser() {
rc := rand.Intn(6)
color(BRed)
switch rc {
case 0:
progWrite("Go on, ", 50); wait(500); progWrite("blame the system, ", 50); wait(500); progWrite("whatever.", 50)
case 1:
progWrite("Buddy Youngster's pizza delivery", 50)
case 2:
progWrite("Lmao.", 200)
case 3:
progWrite("You had it all, buddy", 50)
case 4:
progWrite("House wins. ", 50); wait(800); progWrite("Again.", 50)
case 5: // subject status
seedRNG()
rep := rand.Intn(5)
progWrite("SUBJECT REPORT: ", 50)
wait(800)
switch rep {
case 0:
progWrite("Needs job.", 50)
case 1:
progWrite("Outplayed.", 50)
case 2:
progWrite("Bad with money.", 50)
case 3: