Skip to content

Commit

Permalink
Evolved Incremental
Browse files Browse the repository at this point in the history
First draft of Evolved Incremental.

Can complete initial evolution, not much else yet.
  • Loading branch information
pmotschmann committed Dec 7, 2018
1 parent f8c0e1f commit f2a5604
Show file tree
Hide file tree
Showing 11 changed files with 1,274 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
*#
727 changes: 727 additions & 0 deletions actions.js

Large diffs are not rendered by default.

Binary file added evolved.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions evolved.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.main {
margin-top: 1rem;

.race {
margin-top: .75rem;
}

.resources {
margin-top: 1rem;
.resource {
display: flex;
:first-child {
width: 40%;
}
:nth-child(2) {
text-align: right;
width: 40%;
display: block;
}
}
}

.content {
.tab-content {
padding: 0 1rem 1rem;
}
.tab-item {
padding: 0 0 3rem 1rem;
}
a.button {
width: 10rem;
margin: 1rem 1rem 0 0;
}
}

> div.popper {
margin-top: .125rem;
text-align: center;
padding: 1rem;
max-width: 18rem;
border-radius: .25rem;
> div:nth-child(2),
> div:nth-child(3) {
border-top: solid 1px black;
}
}
}
46 changes: 46 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Evolved</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<link rel="icon" href="evolved.ico" type="images/x-icon">
<link rel="stylesheet" href="https://unpkg.com/buefy/dist/buefy.min.css">
<link rel="stylesheet" href="https://unpkg.com/bulmaswatch/darkly/bulmaswatch.min.css">
<link rel="stylesheet/less" type="text/css" href="evolved.less">
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/[email protected]/dist/buefy.min.js"></script>
<script src="https://unpkg.com/popper.js/dist/umd/popper.min.js"></script>
<script src="lib/less.min.js"></script>
<script src="lib/lz-string.min.js"></script>
<script src="vars.js"></script>
<script src="races.js"></script>
<script src="traits.js"></script>
<script src="resources.js"></script>
<script src="actions.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="main" class="main container">
<div class="columns is-gapless">

<div class="column is-one-quarter">
<div id="race" class="race">
<b-tooltip :label="desc()" position="is-right" type="is-dark" size="is-large" multilined animated>{{ name() }}</b-tooltip>
</div>
<div id="resources" class="resources"></div>
</div>
<div class="column is-three-quarters">
<div id="tabs" class="content">
<b-tabs v-model="civTabs">
<b-tab-item id="evolution" label="Evolve"></b-tab-item>
<b-tab-item id="city" label="Village" v:hidden></b-tab-item>
<b-tab-item id="tech" label="Research"></b-tab-item>
</b-tabs>
</div>
</div>

</div>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions lib/less.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/lz-string.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

198 changes: 198 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
// Main game init
$(function() {
//localStorage.clear();
var global_data = save.getItem('global') || false;
if (global_data) {
// Load preexiting game data
global = JSON.parse(global_data);
Math.seed = global.seed;
}
else {
newGame();
}

vues['vue_tabs'] = new Vue(main_tabs);
vues['vue_tabs'].$mount('#tabs');

// Load Resources
defineResources();

vues['race'] = new Vue({
data: global.race,
methods: {
name: function(){
return races[global.race.species].name;
},
desc: function(){
return races[global.race.species].desc;
}
}
});
vues['race'].$mount('#race');

if (global.race.species === 'protoplasm'){
global.resource.RNA.display = true;
addAction('evolution','rna');
var evolve_actions = ['dna','membrane','organelles','nucleus','eukaryotic_cell','mitochondria'];
for (var i = 0; i < evolve_actions.length; i++) {
if (global.race[evolve_actions[i]]){
addAction('evolution',evolve_actions[i]);
}
}
if (global.race['sexual_reproduction'] && !global.race['phagocytosis'] && !global.race['chloroplasts'] && !global.race['chitin']){
addAction('evolution','sexual_reproduction');
}
else if (global.race['phagocytosis'] && global.race['phagocytosis'].count == 0){
addAction('evolution','phagocytosis');
}
else if (global.race['chloroplasts'] && global.race['chloroplasts'].count == 0){
addAction('evolution','chloroplasts');
}
else if (global.race['chitin'] && global.race['chitin'].count == 0){
addAction('evolution','chitin');
}
else if ((global.race['phagocytosis'] || global.race['chloroplasts'] || global.race['chitin']) && !global.race['multicellular']){
if (global.race['phagocytosis']){
addAction('evolution','phagocytosis');
}
else if (global.race['chloroplasts']){
addAction('evolution','chloroplasts');
}
else if (global.race['chitin']){
addAction('evolution','chitin');
}
}
else {
var late_actions = ['multicellular','spores','poikilohydric','bilateral_symmetry','bryophyte','protostomes','deuterostome','vascular','homoiohydric','athropods','mammals','eggshell','sentience'];
for (var i = 0; i < late_actions.length; i++) {
if (global.race[late_actions[i]] && global.race[late_actions[i]].count == 0){
addAction('evolution',late_actions[i]);
}
}
}
}
else {
var city_actions = ['food','lumber','stone'];
for (var i = 0; i < city_actions.length; i++) {
if (global.city[city_actions[i]]){
addAction('city',city_actions[i]);
}
}
}

// Start game loop
mainLoop();
});

// Main game loop
function mainLoop() {
intervals['main'] = setInterval(function() {

if (global.race.species === 'protoplasm'){
// Early Evolution Game
if (global.race['nucleus'] && global['resource']['DNA'].amount < global['resource']['DNA'].max){
var increment = global.race['nucleus'].count;
while (global['resource']['RNA'].amount < increment * 2){
increment--;
if (increment <= 0){ break; }
}
var count = global['resource']['DNA'].amount + increment;
if (count > global['resource']['DNA'].max){ count = global['resource']['DNA'].max; }
global['resource']['DNA'].amount = count;
global['resource']['RNA'].amount -= increment * 2;
}
if (global['resource']['RNA'].amount < global['resource']['RNA'].max){
if (global.race['organelles']){
var count = global['resource']['RNA'].amount + global.race['organelles'].count + 1;
if (count > global['resource']['RNA'].max){ count = global['resource']['RNA'].max; }
global['resource']['RNA'].amount = count;
}
else {
global['resource']['RNA'].amount++;
}
}
if (global.race['membrane'] && global.race['membrane'].count >= 1 && !global.race['dna']){
global.race['dna'] = 1;
addAction('evolution','dna');
global.resource.DNA.display = true;
}
if (global['resource']['RNA'].amount >= 10 && !global.race['membrane']){
global.race['membrane'] = { count: 0 };
addAction('evolution','membrane');
}
if (global['resource']['DNA'].amount >= 5 && !global.race['organelles']){
global.race['organelles'] = { count: 0 };
addAction('evolution','organelles');
}
if (global.race['organelles'] && global.race['organelles'].count >= 1 && !global.race['nucleus']){
global.race['nucleus'] = { count: 0 };
addAction('evolution','nucleus');
}
if (global.race['nucleus'] && global.race['nucleus'].count >= 1 && !global.race['eukaryotic_cell']){
global.race['eukaryotic_cell'] = { count: 0 };
addAction('evolution','eukaryotic_cell');
}
if (global.race['eukaryotic_cell'] && global.race['eukaryotic_cell'].count >= 1 && !global.race['mitochondria']){
global.race['mitochondria'] = { count: 0 };
addAction('evolution','mitochondria');
}
if (global.race['mitochondria'] && global.race['mitochondria'].count >= 1 && !global.race['sexual_reproduction']){
global.race['sexual_reproduction'] = { count: 0 };
addAction('evolution','sexual_reproduction');
}
}
else {
// Rest of game
}

// Save game state
save.setItem('global',JSON.stringify(global));
}, 1000);
}

function addAction(action,type){

var id = actions[action][type].id;
var element = $('<a id="'+id+'" class="button is-dark" v-on:click="action">{{ title }}</a>');
$('#'+action).append(element);
vues[id] = new Vue({
data: {
title: typeof actions[action][type].title === 'string' ? actions[action][type].title : actions[action][type].title()
},
methods: {
action: function(){ actions[action][type].action() }
},
});
vues[id].$mount('#'+id);
var popper = $('<div id="pop'+id+'" class="popper has-background-light has-text-dark"></div>');
popper.hide();
actionDesc(popper,action,type);
$('#main').append(popper);
$('#'+id).on('mouseover',function(){
popper.show();
new Popper($('#'+id),popper);
});
$('#'+id).on('mouseout',function(){
popper.hide();
});
}

function actionDesc(parent,action,type){
parent.append($('<div>'+actions[action][type].desc+'</div>'));
if (actions[action][type].cost){
var cost = $('<div></div>');
Object.keys(actions[action][type].cost).forEach(function (res) {
cost.append($('<div>'+res+': '+actions[action][type].cost[res]()+'</div>'));
});
parent.append(cost);
}
if (actions[action][type].effect){
parent.append($('<div>'+actions[action][type].effect+'</div>'));
}
}

function newGame(){
global['race'] = { species : 'protoplasm' };
Math.seed = Math.rand(0,1000);
global.seed = Math.seed;
}
Loading

0 comments on commit f2a5604

Please sign in to comment.