This repository was archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.nut
More file actions
151 lines (141 loc) · 4.73 KB
/
main.nut
File metadata and controls
151 lines (141 loc) · 4.73 KB
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
require("company.nut");
require("utility.nut");
class TeamDuude extends GSController {
loadedgame = null;
constructor() {
loadedgame = null;
}
}
function TeamDuude::Start() {
this.Init(loadedgame);
// this.Sleep(74);
local loop = 0;
while (true) {
loop++;
if ((loop % 10) == 0) {
CheckAccept();
}
HandleEvents();
this.Sleep(7);
}
}
function TeamDuude::Init(loaded) {
for (local i = 0; i < 15; i++) {
// CacheDuude.cargo_handle.AddItem(i, 0);
CacheDuude.vehicle[i] = GSList();
}
local caching = CompanyDuude();
// CacheDuude.FindCargoUsage();
local loadlimit = (loaded != null);
if (loadlimit) {
for (local i = 0; i < loaded.ccPage.len(); i++) { CompanyDuude.cPage[i] = loaded.ccPage[i]; }
for (local i = 0; i < loaded.ccRank.len(); i++) { CompanyDuude.gElement[i] = loaded.ccRank[i]; }
for (local i = 0; i < 15; i++) { CompanyDuude.NewCompany(i); }
// GSLog.Info("savegame type="+typeof(loaded.element)+" datasize="+loaded.element.len());
// for (local i = 0; i < loaded.bigdata.len(); i++) { CacheDuude.bigarray[i] = loaded.bigdata[i]; }
local x = 0;
local buff = [];
}
CompanyDuude.Init();
GSLog.Info("Welcome use page " + CompanyDuude.GetPageID(15, 0));
GSLog.Info("Rules use page " + CompanyDuude.GetPageID(16, 0));
GSLog.Info("Settings use page " + CompanyDuude.GetPageID(17, 0));
GSLog.Info("Stuff use page " + CompanyDuude.GetPageID(18, 0));
GSLog.Info("Links use page " + CompanyDuude.GetPageID(19, 0));
// GSLog.Info("Goals use page "+CompanyDuude.GetPageID(20,0));
CacheDuude.GetSnowTown();
local wait = 0 * 30 * 74
wait = true;
GSLog.Warning("Waiting companies...");
while (wait)
for (local i = 0; i < 15; i++) {
if (GSCompany.ResolveCompanyID(i) != GSCompany.COMPANY_INVALID) {
CompanyDuude.StoryUpgrade();
wait = false;
GSLog.Warning("Company found.");
break;
}
}
}
function TeamDuude::HandleEvents() {
if (GSEventController.IsEventWaiting()) {
local event = GSEventController.GetNextEvent();
if (event == null) return;
local eventType = event.GetEventType();
switch (eventType) {
case GSEvent.ET_COMPANY_NEW: {
local e = GSEventCompanyNew.Convert(event);
local c = e.GetCompanyID();
CompanyDuude.NewCompany(c);
GSController.Sleep(7);
CompanyDuude.Question(c);
// if (!GSWindow.IsOpen(GSWindow.WC_GOAL_QUESTION, 0)) {
// GSWindow.Highlight(GSWindow.WC_MAIN_TOOLBAR, 0, GSWindow.WID_TN_STORY, GSWindow.TC_WHITE);
// }
break;
}
case GSEvent.ET_COMPANY_BANKRUPT: {
local e = GSEventCompanyBankrupt.Convert(event);
local c = e.GetCompanyID();
CompanyDuude.RemoveCompany(c);
GSLog.Warning("Bankrupt company removing " + GSCompany.GetName(c));
break;
}
case GSEvent.ET_GOAL_QUESTION_ANSWER: {
local e = GSEventGoalQuestionAnswer.Convert(event);
local i = e.GetUniqueID();
local c = e.GetCompany();
local b = e.GetButton();
if (GSStoryPage.IsValidStoryPage(CompanyDuude.GetPageID(c, 0))) {
CompanyDuude.gElement[i] = GSStoryPage.NewElement(CompanyDuude.GetPageID(c, 0), )
}
if (b == GSGoal.BUTTON_ACCEPT) {
if (GSGoal.IsValidGoal(i)) {
GSGoal.SetText(i, GSText(GSText.STR_ACCEPTED_RULES, c));
GSGoal.SetCompleted(i, true);
}
if (GSGoal.IsValidGoal(CompanyDuude.GetGoalID(15))) {
GSGoal.SetText(CompanyDuude.GetGoalID(15), GSText(GSText.STR_ACCEPTED_RULES, c));
GSGoal.SetCompleted(CompanyDuude.GetGoalID(15), true);
}
GSStoryPage.Show(CompanyDuude.GetPageID(c, 0));
GSLog.Warning("Company #" + c + " " + GSCompany.GetName(c) + " accepted rules");
} else if (b == GSGoal.BUTTON_DECLINE) {
TeamDuude.FeedTheDuude(c, i);
GSLog.Warning("Company #" + c + " " + GSCompany.GetName(c) + " declined rules muahhhahaha");
} else {
}
}
break;
}
}
}
function TeamDuude::CheckAccept() {
}
function TeamDuude::FeedTheDuude(c, i) {
if (GSCompany.ResolveCompanyID(c) != GSCompany.COMPANY_INVALID) {
GSCompany.ChangeBankBalance(GSCompany.ResolveCompanyID(c), -GSCompany.GetBankBalance(GSCompany.ResolveCompanyID(c)) * 99, GSCompany.EXPENSES_OTHER, GSMap.TILE_INVALID);
if (GSGoal.IsValidGoal(i)) {
GSGoal.SetText(i, "Well... Try to survive");
GSGoal.SetCompleted(i, true);
}
if (GSGoal.IsValidGoal(CompanyDuude.GetGoalID(15))) {
GSGoal.SetText(CompanyDuude.GetGoalID(15), GSText(GSText.STR_DECLINED_RULES, c));
GSGoal.SetCompleted(CompanyDuude.GetGoalID(15), true);
}
}
}
function TeamDuude::Load(version, data) {
GSLog.Info("Loading savegame version "+version);
loadedgame = data;
}
function TeamDuude::Save() {
GSLog.Info("saving...");
local table = {
ccPage = null,
ccRank = null,
}
table.ccPage = CompanyDuude.cPage;
table.ccRank = CompanyDuude.gElement;
return table;
}