Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script src="https://unpkg.com/sortablejs@1.10.2/Sortable.min.js" integrity="sha384-6qM1TfKo1alBw3Uw9AWXnaY5h0G3ScEjxtUm4TwRJm7HRmDX8UfiDleTAEEg5vIe" crossorigin="anonymous"></script>
<script src="https://unpkg.com/chart.js@3.8.2/dist/chart.min.js" integrity="sha384-z7c1KnSCkMpfoib43Lq1v2pokQC8cdqBWmH2qiyH2KkmNv60hACtZUjoCEkp1Y08" crossorigin="anonymous"></script>
<script src="lib/lz-string.min.js"></script>
<script src="evolve/main.js" type="module"></script>
<script src="src/main.js" type="module"></script>
</head>
<body>
<style>
Expand Down
400 changes: 231 additions & 169 deletions src/actions.js

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions src/compare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

//I removed everything that wasn't changed from an example struct
const actions={
rock_quarry: {
effect(){
let stone = actions.city.rock_quarry.caps.Stone();
let asbestos = global.race['smoldering'] ? `<div>${loc('plus_max_resource',[stone,global.resource.Chrysotile.name])}</div>` : '';
if (global.tech['mine_conveyor']){
return `<div>${loc('city_rock_quarry_effect1',[2])}</div><div>${loc('plus_max_resource',[stone,global.resource.Stone.name])}</div>${asbestos}<div class="has-text-caution">${loc('city_rock_quarry_effect2',[4,$(this)[0].powered()])}</div>`;
}
else {
return `<div>${loc('city_rock_quarry_effect1',[2])}</div><div>${loc('plus_max_resource',[stone,global.resource.Stone.name])}</div>${asbestos}`;
}
},
caps:{
Stone(count){
return BHStorageMulti((count??1) * spatialReasoning(100));
},
Chrysotile(count){
return actions.city.rock_quarry.caps.Stone(count)
},
},
},
}
// Here is the class (will explain)
class AMOUNT{
constructor(action,globl,name,is_true,resource,title,count){
this.name=name//name of struct
this.resource=null
this.action=action
this.global=globl
/*
If the cap name is a string -> make it a list because then we can remove other checks later
if its undefined -> we can just get it from the actions struct (this will be updated later for reasons that i cant remember, imma think on that lol)
if its anything else (so a list) -> its good

*/
if(typeof this.resource === 'string'){
this.resource=[resource]
}
else if(resource === undefined){
this.resource=Object.keys(this.action.caps)
}
else{
this.resource=resource
}
this.is_true=is_true//can we actually add the caps?
this.title=title//whats its name

}
calc(){
this.is_true=this.global.hasOwnProperty(this.name)//make sure it works still
this.title=typeof this.action.title ==="string"?this.action.title : this.action.title()//get title, with in case of function
}
}

function Amount(action,globl,name,resource,is_true,title){
return new AMOUNT(action,globl,name,resource,is_true,title)
}
function c_Amount(name,resource,is_true,title){
return new AMOUNT(actions.city[name],global.city,name,resource,is_true,title)
}
function sh_Amount(name,resource,is_true,title){
return new AMOUNT(actions.space.spc_home[name],global.space,name,resource,is_true,title)
}
//the list
let capsIncrease=[
c_Amount('rock_quarry'),
]


//everythin above is outside of midLoop
//everything below is inside

for(let i in capsIncrease){
let inc=capsIncrease[i]
inc.calc();//make sure everything is correct
let is_true=inc.is_true, resource=inc.resource, name=inc.name, title=inc.title;//relic of creation of this, will remove when its finished

if(!is_true||!name)break//if its false or doesnt have a name dont add anything
//checks first if it has anything on, then any support on, then finally just uses the struct count
let struct_count=p_on[name] != undefined? p_on[name] : (support_on[name] != undefined ? support_on[name] != undefined : inc.global[name].count)
resource.forEach(res=>{
let gain=inc.action.caps[res](struct_count);// get the gain per resource
if(res=='Pop'){
res=global.race.species
}
//if it isn't undefined or null, add stuff in
//this is because somethings have other conditions, banks only give money if you dont have cataclysm and a spaceport on
if(gain!=undefined && gain !=null){
caps[res]+=gain;
breakdown.c[res][title]=gain+'v';
}
})
}
Empty file added src/condense.js
Empty file.
112 changes: 102 additions & 10 deletions src/governor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { global, seededRandom, p_on, breakdown } from './vars.js';
import { vBind, popover, tagEvent, calcQueueMax, calcRQueueMax, clearElement, adjustCosts, decodeStructId, timeCheck, arpaTimeCheck, hoovedRename } from './functions.js';
import { vBind, popover, tagEvent, calcQueueMax, calcRQueueMax, clearElement, adjustCosts, decodeStructId, timeCheck, arpaTimeCheck, hoovedRename, deepClone } from './functions.js';
import { races } from './races.js';
import { actions, checkCityRequirements, housingLabel, wardenLabel, updateQueueNames, checkAffordable, drawTech, drawCity } from './actions.js';
import { govCivics, govTitle } from './civics.js';
Expand Down Expand Up @@ -417,6 +417,38 @@ function dragSpyopList(gov){
}
}

function getKeyByValue(obj, value) {
return Object.keys(obj).find(key => obj[key] === value);
}
function createGovConfigName(task,name){
if(!name || name=="name"){
let config=global.race.governor.config.saves[task]
name=0;
Object.keys(config).forEach(elm=>{
if(typeof elm=="number"){
name=Math.max(name,parseInt(elm))
}
})
name=name+1
}
return name
}
function createGovConfig(task,name){
let config;
name=createGovConfigName(task,name)

if(!global.race.governor.config.saves[task]){
config={}
}
else{
config=global.race.governor.config.saves[task]
}

global.race.governor.config.saves.name=name;
config[name]=deepClone(global.race.governor.config[task])
global.race.governor.config.saves[task]=config
}

export function drawnGovernOffice(){
clearSpyopDrag();
let govern = $(`<div id="govOffice" class="govOffice"></div>`);
Expand Down Expand Up @@ -459,7 +491,31 @@ export function drawnGovernOffice(){
global.race.governor['config'] = {};
}

let options = $(`<div class="options"><div>`);
let config=$(`<div id="saveLoadTasks" class="govTask"></div>`);
govern.append(config);

let config_opt=``;
Object.keys(gov_tasks).forEach(function(task){
if(gov_tasks[task].req()){//v-show="activeTask('${task}')"
config_opt+=`<b-dropdown-item v-on:click="setTask('${task}',10);">{{ '${task}' | label }}</b-dropdown-item>`
}
})
config.append(/*html*/`
<span>${loc(`gov_task`,["Load / Save"])}</span>
<b-dropdown hoverable>
<button class="button is-primary" slot="trigger">
<span>{{ t.t10 | label }}</span>
<i class="fas fa-sort-down"></i>
</button>
<b-dropdown-item v-on:click="setTask('none',10)">{{ 'none' | label }}</b-dropdown-item>
${config_opt}
</b-dropdown>
<b-button v-on:click="loadConfig(t.t10,c.saves.name)">Load</b-button>
<b-button v-on:click="saveConfig(t.t10,c.saves.name)">Save</b-button>
<b-input v-model="c.saves.name" :controls="false"></b-input>`)//:v-html="c.saves.name"


let options = $(`<div class="options"></div>`);
govern.append(options);

//Configs
Expand Down Expand Up @@ -700,21 +756,28 @@ export function drawnGovernOffice(){
}
});
}
tagEvent('govtask',{
'task': t
});
if(n!==10){
tagEvent('govtask',{
'task': t
});
}
vBind({el: `#race`},'update');
},
showTask(t){
return Object.values(global.race.governor.tasks).includes(t)
return (Object.values(global.race.governor.tasks).includes(t)
|| (Object.values(global.race.governor.tasks).includes('combo_storage') && ['storage','bal_storage'].includes(t))
|| (Object.values(global.race.governor.tasks).includes('combo_spy') && ['spy','spyop'].includes(t));
|| (Object.values(global.race.governor.tasks).includes('combo_spy') && ['spy','spyop'].includes(t))) && Object.keys(global.race.governor.tasks).map(key=>{
if(key!="t10"){
return global.race.governor.tasks[key]
}
}).includes(t);
},
activeTask(t){
let activeTasks = [];
if (global.race.hasOwnProperty('governor')){
Object.keys(global.race.governor.tasks).forEach(function(ts){
if (global.race.governor.tasks[ts] !== 'none'){
// console.log(ts,"t10")
if (global.race.governor.tasks[ts] !== 'none' && ts !== "t10"){
activeTasks.push(global.race.governor.tasks[ts]);
}
});
Expand Down Expand Up @@ -760,7 +823,27 @@ export function drawnGovernOffice(){
},
trashLabel(r){
return loc(global.race.governor.config.trash[r].s ? `gov_task_trash_max` : `gov_task_trash_min`,[global.resource[r].name]);
}
},
saveConfig(t,n){
// console.log(global.race.governor.config)
// if(!global.race.governor.config.saves){
// global.race.governor.config.saves={name:'0'}
// }
createGovConfig(t,n)
},
loadConfig(t,n){
let saves=global.race.governor.config.saves
if(!saves.hasOwnProperty(t)){
console.log("you have no save for the task ",t)
return
}
if(!saves[t].hasOwnProperty(n)){
console.log("you have no save for the task ",t," named ",n)
return
}
global.race.governor.config[t]=global.race.governor.config.saves[t][n]
console.log("here is config",global.race.governor.config[t],global.race.governor.config.saves[t][n])
},
},
filters: {
label(t){
Expand All @@ -779,7 +862,16 @@ export function drawnGovernOffice(){
{
elm: `#govOffice .bg`,
});

popover(`saveLoadTasks`,function(){
let gov=global.race.governor
// console.log(gov.config.saves)
let desc=`<div>Current Saves: ${gov.tasks.t10}</div><div>${gov.config.saves[gov.tasks.t10]?Object.keys(gov.config.saves[gov.tasks.t10]).join(', '):'None'}</div>`
//'Hey there'+
return desc
},{
elm:`#saveLoadTasks`,
})

Object.keys(global.civic.foreign).forEach(function (gov){
dragSpyopList(gov);
});
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ export function index(){
<b-dropdown-item v-on:click="setTheme('gruvboxDarkRG')">{{ 'theme_gruvboxDarkRG' | label }}</b-dropdown-item>
<b-dropdown-item v-on:click="setTheme('orangeSoda')">{{ 'theme_orangeSoda' | label }}</b-dropdown-item>
<b-dropdown-item v-on:click="setTheme('dracula')">{{ 'theme_dracula' | label }}</b-dropdown-item>
<b-dropdown-item v-on:click="setTheme('custom')">{{ 'theme_dracula' | label }}</b-dropdown-item>
${hideEgg}
</b-dropdown>

Expand Down Expand Up @@ -1502,4 +1503,5 @@ export function index(){
</span>
</div>
`);
// document.documentElement.style.setProperty('--customTheme-html-background','#0f0');
}
Loading