mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
First tilde projects commit
This commit is contained in:
1 parent
9bcadfc4a7
commit
726861fae6
40 files changed
+20890
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,72 @@
|
||||
(function(angular) {
|
||||
'use strict';
|
||||
|
||||
angular.module('MissionApp',[]);
|
||||
|
||||
function MissionController() {
|
||||
|
||||
var self = this;
|
||||
|
||||
var adjectives = Array('Bold','Breaking','Brilliant','Crescent','Dark|Darkness','Desert|Desert','Evening|Darkness','Final','First','July','Last','Libery|Liberty','Magic|Magic','Morning|Morning','Power|Power','Phantom','Present','Roaring|Roar|Scream','Rolling','Sand','Screaming','Soaring','Standing|Stand','Star|Star','Urgent','Utopian','Valiant');
|
||||
var nouns = Array('Action','Alert','Beauty','Claw','Darkness','Dawn','Day','Desert','Envy','Fall','Fist','Flight','Fury','Guard','Hammer','Hand','Honor','Hope','Hurricane','Liberty','Light','Lightning','Magic','Morning','October','Power','Rain','Repose','Roar','Scream','Skull','Shield','Stand','Star','Storm','Streak','Sun','Thunder','Wind','Wrath');
|
||||
var colors = Array('Black','Blue','Brown','Gray','Green','Indego','Orange','Purple','Rainbow','Red','Scarlet','Violet','White','Yellow');
|
||||
var actors = Array('Condor','Eagle','Guardian','Hawk','Hydra','Lady','Lion','Scorpion','Spartan','Titan','Victor','Viking','Warrior');
|
||||
var mission_grammars = Array(
|
||||
{chance:30, grammar: 'adj1 + " " + noun1'},
|
||||
{chance:10, grammar: 'color + " " + noun1'},
|
||||
{chance:10, grammar: 'color + " " + actor'},
|
||||
{chance:10, grammar: 'actor +"\'s " + noun1'},
|
||||
{chance:10, grammar: 'noun1 + " of the " + noun2'},
|
||||
{chance:10, grammar: 'noun1 + " of " + noun2'},
|
||||
{chance:10, grammar: 'adj1 + " " + noun1 + " and " + adj2 + " " + noun2'},
|
||||
{chance:3, grammar: '"Attack of the " + actors + "s"'}
|
||||
);
|
||||
this.getNoun = function(badNouns) {
|
||||
return _.chain(nouns)
|
||||
.difference(badNouns)
|
||||
.sample()
|
||||
.value();
|
||||
};
|
||||
|
||||
this.getMissionName = function() {
|
||||
var adj1 = _.sample(adjectives);
|
||||
var adj2 = _.sample(adjectives);
|
||||
while(adj1 == adj2)
|
||||
adj2 = _.sample(adjectives);
|
||||
var badWords = _.uniq(adj1.split('|').slice(1).concat(adj2.split('|').slice(1)));
|
||||
var noun1 = self.getNoun(badWords);
|
||||
var noun2 = self.getNoun(badWords);
|
||||
while(noun1 == noun2)
|
||||
noun2 = self.getNoun(badWords);
|
||||
adj1 = adj1.split('|')[0];
|
||||
adj2 = adj2.split('|')[0];
|
||||
var color = _.sample(colors);
|
||||
var actor = _.sample(actors);
|
||||
|
||||
var mission = '';
|
||||
var rand = Math.floor(Math.random() * 100 + 1);
|
||||
if(rand <= 25)
|
||||
mission += 'Operation ';
|
||||
else if(rand <= 50)
|
||||
mission += 'Project ';
|
||||
else if(rand <= 75)
|
||||
mission += 'Code: ';
|
||||
|
||||
var sumChance = _.chain(mission_grammars).pluck('chance').reduce(function(sum, c) { return sum + c;}).value();
|
||||
rand = Math.floor(Math.random() * sumChance + 1);
|
||||
for(var gi in mission_grammars) {
|
||||
var g = mission_grammars[gi];
|
||||
if(rand > g.chance) {
|
||||
rand -= g.chance;
|
||||
}
|
||||
else {
|
||||
mission += eval(g.grammar);
|
||||
return mission;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
};
|
||||
|
||||
angular.module('MissionApp').controller('MissionController', [MissionController]);
|
||||
}(window.angular));
|
||||
@@ -0,0 +1,48 @@
|
||||
module Mission
|
||||
|
||||
@adjectives = []
|
||||
@nouns = []
|
||||
@colors = []
|
||||
@animals = []
|
||||
@mission_grammars = []
|
||||
|
||||
|
||||
def Mission.get_name()
|
||||
adj, bad_nouns = get_adj();
|
||||
noun = get_noun(bad_nouns)
|
||||
|
||||
adj2 = adj
|
||||
noun2 = noun
|
||||
while adj2[0] == adj[0] || noun2 == noun
|
||||
adj2, bad_nouns = get_adj();
|
||||
noun2 = get_noun(bad_nouns)
|
||||
end
|
||||
|
||||
color = get_color()
|
||||
animal = get_animal()
|
||||
|
||||
name = ""
|
||||
case rand(1..100)
|
||||
when 1..10
|
||||
name += "Project "
|
||||
when 11..20
|
||||
name += "Operation "
|
||||
end
|
||||
|
||||
total_prob = 0
|
||||
@mission_grammars.each{|grammar|
|
||||
grammar[0] = grammar[0].to_i
|
||||
total_prob += grammar[0]
|
||||
}
|
||||
chance = rand(1..total_prob)
|
||||
@mission_grammars.each{|grammar|
|
||||
if chance < grammar[0]
|
||||
name += eval(grammar[1])
|
||||
break
|
||||
end
|
||||
chance -= grammar[0]
|
||||
}
|
||||
|
||||
return name
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user