This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { roleLength } = require('utils'); | |
const ROLE_NAME = 'scout'; | |
function spawn(origin, max, roleName, type = 'small') { | |
if (roleLength(Game.creeps, roleName, origin) >= max) { | |
return; | |
} | |
//determine the size to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#comments begin with a pound sign | |
#The script automatically calls the function "main" after loading it | |
#this is how you declare a function called "main" | |
START main: | |
#do stuff | |
END #all functions finish with END | |
#this is how you write a function with arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validateTokenCredentials = (connection) => (fields) => new Promise( (resolve, reject) => { | |
const validateQuery = 'SELECT COUNT(*) AS total FROM sessions WHERE sessions.accountId = ? AND sessions.token = ?;'; | |
return connection.query(validateQuery, [fields.id, fields.token]) | |
.then(results => results[0].total > 0 ? resolve(fields) : reject({msg: 'Invalid password change credentials', extra: [fields.id, fields.token]})) | |
; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//constants | |
var SAVE_NAME = 'cookieCount.foodfare'; | |
//the gameplay variables | |
var cookies = 0; | |
var cursors = 0; | |
var upgrades = 0; | |
//the display variables | |
var cookieNode = document.getElementById('cookies'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//environment variables | |
require('dotenv').config(); | |
//libraries | |
let mysql = require('mysql'); | |
//utilities | |
let { log } = require('./logging.js'); | |
let connection; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//how to call the hitstun animation | |
StartCoroutine(TriggerHit(0.8f)); //0.8 seconds of invulnerability | |
IEnumerator TriggerHit(float delay) { | |
invulnerable = true; //allow for a window of time to get away | |
StartCoroutine(TriggerHitGraphic(0.1f, delay - 0.1f)); | |
yield return new WaitForSeconds(delay); | |
invulnerable = false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (this.state.tagline === 'marquee-loop') { | |
let triangleUpStyle = { | |
flex: '0 1 auto', | |
borderRight: '5px solid', | |
borderBottom: '5px solid', | |
width: '10px', | |
height: '10px', | |
marginLeft: '5px', | |
marginRight: '5px' | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//save data sequentially | |
let counter = 0; | |
let fpath = path.join(__dirname, 'sampledata'); | |
fs.writeFileSync(path.resolve(fpath, `${counter}.json`), 'utf8'); | |
//get the filenames for concatenation as array | |
let filenames = fs.readdirSync(fpath); | |
filenames.forEach(fname => { | |
//concatenate the files | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#new ladder expression | |
SELECT | |
username, | |
recruits, | |
soldiers, | |
gold, | |
(recruits + soldiers + scientists + spies) AS unitTotal, | |
(SELECT COUNT(*) FROM pastCombat WHERE (attackerId = accounts.id AND victor = 'attacker') OR (defenderId = accounts.id AND victor = 'defender')) AS successfulCombats, | |
( | |
(recruits + soldiers + scientists + spies) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class ProgressiveRainbowText extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
colors: props.colors || ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'indigo'], | |
counter: 0, | |
unsubscribeKey: setInterval(() => this.setState({ counter: this.state.counter + 1}), 1000) |