<commit_before>// Incrementer Alpha: Card Collector
// Cookie Click<NAME>
// aka A Place to Start
// uses jquery

var VERSION = 0.02;
var DebugMode = false;
var toolCostMultiplier = 1.15;

$(function() {
	Initialize();
});

var Player = {};

// Saveable game data goes in here
function Game(){
    this.version = 0;
    this.cards = 0;
    this.Tools = {};
    this.Upgrades = {};
	this.income = 0;
    this.wins = 0;
}


// Income = function(){return 1 + 10 * Upgrades['players1']}

function CollectCard(){
	Player.cards++;
	RefreshResources();
}

function BuyTool(tool_id){
    var pt = Player.Tools[tool_id];
    var dt = Data.Tools[tool_id];
	var price = Math.round(pt.curCost);
    if (price <= Player.cards){
			Player.cards -= price;
			pt.count++;
			pt.curCost *= 1.15;
			Player.income += dt.Income();
			RefreshTool(tool_id);
			RefreshResources();
			UnlockTools();
            UnlockUpgrades();
	}
}

function Initialize(){
    LoadGame();
    Data.InitializeUpgrades();
    Data.InitializeTools();
    InitializeToolInterface();
    Interface.InitializeUpgrades();
    Interface.InitializeTabs();
	RefreshResources();
    UnlockTools();
    UnlockUpgrades();
	GameLoop();
}

var gameLoopInterval;
function GameLoop(){
	gameLoopInterval = setInterval(GameStep, 1000);
}

function GameStep(){
	Player.cards += Player.income;
	RefreshResources();
	if ((Player.Tools["player"].locked) && Player.cards >= 10){
		Player.Tools["player"].locked = false;
		Interface.Reveal("player");
	}
	CheckWin();
	Autosave();
}

function UnlockTools(){
	for (var k in Data.Tools){
        if (Data.Tools[k].CheckUnlockCond()){
            Player.Tools[k].locked = false;
            Interface.Reveal(k);
        }
	}
}

function UnlockUpgrades(){
    for (var id in Data.Upgrades){
        if (Data.Upgrades[id].CheckUnlockCond()){
            Player.Upgrades[id].locked = false;
            Interface.RevealUpgrade(id);
        }
	}
}

function CurrentCost(tool){
    var cost = Player.Tools[tool].count * Data.Tools[tool].cost ^ toolCostMultiplier;
    return cost;
}

function CheckWin(){
	if (Player.income > 30000 && !Player.haswon){
        Player.haswon = true;
		alert("You win!");
        Notify("Congratulations, traveler! You won the game!");
		Player.cards = Infinity;
		Player.income = 0;
		clearInterval(gameLoopInterval);
		//for (var k in Player.Tools){
		//	Player.Tools[k].locked = true;
		//	Interface.Hide(k);		
		//}
		RefreshResources();		
	}
}

function SaveGame() {
    var saveData = new Game();
    for (var i in saveData){
        saveData[i] = Player[i];
    }
    Notify("Game saved.");
    localStorage['player'] = btoa(JSON.stringify(saveData));
}

function LoadGame() {
    if (!localStorage['player']){
        Notify("New game started. Hello, traveler!");
        Player = new Game();
        Player.version = VERSION;<commit_msg>Goal cards changed to 3 million<commit_after>// Incrementer Alpha: Card Collector
// Cookie Clicker Ripoff
// aka A Place to Start
// uses jquery

var VERSION = 0.02;
var DebugMode = false;
var toolCostMultiplier = 1.15;

$(function() {
	Initialize();
});

var Player = {};

// Saveable game data goes in here
function Game(){
    this.version = 0;
    this.cards = 0;
    this.Tools = {};
    this.Upgrades = {};
	this.income = 0;
    this.wins = 0;
}


// Income = function(){return 1 + 10 * Upgrades['players1']}

function CollectCard(){
	Player.cards++;
	RefreshResources();
}

function BuyTool(tool_id){
    var pt = Player.Tools[tool_id];
    var dt = Data.Tools[tool_id];
	var price = Math.round(pt.curCost);
    if (price <= Player.cards){
			Player.cards -= price;
			pt.count++;
			pt.curCost *= 1.15;
			Player.income += dt.Income();
			RefreshTool(tool_id);
			RefreshResources();
			UnlockTools();
            UnlockUpgrades();
	}
}

function Initialize(){
    LoadGame();
    Data.InitializeUpgrades();
    Data.InitializeTools();
    InitializeToolInterface();
    Interface.InitializeUpgrades();
    Interface.InitializeTabs();
	RefreshResources();
    UnlockTools();
    UnlockUpgrades();
	GameLoop();
}

var gameLoopInterval;
function GameLoop(){
	gameLoopInterval = setInterval(GameStep, 1000);
}

function GameStep(){
	Player.cards += Player.income;
	RefreshResources();
	if ((Player.Tools["player"].locked) && Player.cards >= 10){
		Player.Tools["player"].locked = false;
		Interface.Reveal("player");
	}
	CheckWin();
	Autosave();
}

function UnlockTools(){
	for (var k in Data.Tools){
        if (Data.Tools[k].CheckUnlockCond()){
            Player.Tools[k].locked = false;
            Interface.Reveal(k);
        }
	}
}

function UnlockUpgrades(){
    for (var id in Data.Upgrades){
        if (Data.Upgrades[id].CheckUnlockCond()){
            Player.Upgrades[id].locked = false;
            Interface.RevealUpgrade(id);
        }
	}
}

function CurrentCost(tool){
    var cost = Player.Tools[tool].count * Data.Tools[tool].cost ^ toolCostMultiplier;
    return cost;
}

function CheckWin(){
	if (Player.income > 3000000 && !Player.haswon){
        Player.haswon = true;
		alert("You win!");
        Notify("Congratulations, traveler! You won the game!");
		Player.cards = Infinity;
		Player.income = 0;
		clearInterval(gameLoopInterval);
		//for (var k in Player.Tools){
		//	Player.Tools[k].locked = true;
		//	Interface.Hide(k);		
		//}
		RefreshResources();		
	}
}

function SaveGame() {
    var saveData = new Game();
    for (var i in saveData){
        saveData[i] = Player[i];
    }
    Notify("Game saved.");
    localStorage['player'] = btoa(JSON.stringify(saveData));
}

function LoadGame() {
    if (!localStorage['player']){
        Notify("New game started. Hello, traveler!");
        Player = new Game();
        Player.version = VERSION;
{'fraction_non_alphanumeric': 0.1554819592121318, 'fraction_numerical': 0.010632734878856544, 'mean_word_length': 3.1609862218999276, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3237016', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1838, 'n_words': 417}