Skip to content

Instantly share code, notes, and snippets.

@susanndelgado
Last active December 17, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susanndelgado/5677669 to your computer and use it in GitHub Desktop.
Save susanndelgado/5677669 to your computer and use it in GitHub Desktop.
Love game is a project I put together for School - What it does is it takes two names and calculates it in two different ways against each other to reveal love matches. First it will calculate a percent in a not so mathematical way. The code will evaluate the number of times a letter appears in each name then move it to an array that will later …
function gameSetup(){
var trueLove= []; //used for calculation of the percent
var flamesOne= [];//used for flames values you
var flamesTwo= [];//user for flame values partner
//first person
var $youFname = $("#you input.fname").val();
var $youLname = $("#you input.lname").val();
var $youName= $youFname.toLowerCase()+$youLname.toLowerCase();
var youArray = $youName.split("");
//second person
var $partnerFname = $("#partner input.fname").val();
var $partnerLname = $("#partner input.lname").val();
var $partnerName= $partnerFname.toLowerCase()+$partnerLname.toLowerCase();
var partnerArray = $partnerName.split("");
for(var i in youArray) {
var value = youArray[i];
trueLove.push(value);
var temp = "";
//check letters against other name
for(var a in partnerArray){
if(partnerArray[a] === value){
temp = "";
break;
} else if(partnerArray[a] != value){
temp = value;
}
}
if(temp === value){
flamesOne.push(value);
}
}
//push the love word to trueLove game variable
trueLove.push("l","o","v","e","s");
for(var i in partnerArray) {
var value = partnerArray[i];
trueLove.push(value);
var temp = "";
//check letters against other name
for(var a in youArray){
if(youArray[a] === value){
temp = "";
break;
} else if(youArray[a] != value){
temp = value;
}
}
if(temp === value){
flamesTwo.push(value);
}
}
//count letters that remain in each name for flames
var countYou = flamesOne.length;
var countPartner = flamesTwo.length;
flamesPredictions(countYou,countPartner);
mathsetup(trueLoveGame(trueLove));
}
var brief = {
"0": "Vitalized Couple. This type of couple has the highest level of satisfaction across all categories"+
"They were very high in marital interaction scores "+
"meaning they were comfortable with their partner\'s personality" +
"habits communication and conflict resolution",
"1": "Harmonious Couple. This couple type has moderately high scores "+
"second to vitalized couples but their levels of" +
"agreement on parenting issues were lower "+
"and this couple will more than likely have the fewest children often one child",
"2": "Traditional Couple. This couple had higher than average scores,"+
"and were the most satisfied group in handling children and parenting duties.",
"3": "Conflicted Couple. This type of couple has moderately low scores in the Enrich"+
"inventory overall, but were higher in religious aspects. "+
"Their lowest scores were in the marital relationship areas of" +
"conflict resolution and communication. ",
"4": "Devitalized Couple. This type of couple has the lowest of all Enrich scores. The couples "+
"are very dissatisfied in their relationship and has considered breaking up. "
}
var relationship ={
"0": "Be Friends",
"1": "Be Lovers",
"2": "Be Affectionate",
"3": "Get Married",
"4": "Become Enemies",
"5": "Have Sex",
"6": "Be Friends",
"7": "Be Lovers",
"8": "Be Affectionate",
"9": "Get Married"
}
var perdictions = {
"0": "The Duty Fulfiller:"+
"as good as gold, and they honor their commitments faithfully."+
"They believe that to do otherwise would be nothing less than a breach of honor and trustworthiness. "+
"Consequently, they take their vows very seriously, and once they have said \"I do\", that means they are bound to the relationship until \"death do us apart\" or otherwise. "+
"Driven to fulfill their responsibilities and duties, and will do so with tireless effort."+
"They will do their best to meet the obligations presented by the different relationship roles which they play during their lives, spouse, parent, offspring, etc."+
"They may have difficulty showing warmth, but they frequently feel it in abundance, and most develop the ability to show it through sheer effort."+
"If nothing else, the person holds the gold medal of all the personality types for Effort. "+
"They will put forth tremendous amounts of effort to accomplish goals which are important to them. "+
"If healthy relationships are among these goals, you can bet that this person will do everything that they can to foster and maintain healthy relationships.",
"1": "The Guardian:"+
"are very enthusiastic people who are driven to fulfill their obligations and duties,"+
" especially those towards their families. Their priorities generally put God first,"+
" family second, and friends third. They put forth a tremendous amount of effort to meet their obligations and duties," +
" according to their priorities. They are dedicated and committed to their relationships, "+
"which they consider to be lifelong and unalterable. "+
"They like to be in charge, and may be very controlling of their mates and children. "+
"They have high esteem for traditions and institutions,"+
" and expect that their mates and children will support these as well. "+
"They have little patience and need for dealing with people who see things very differently from them.",
"2": "The Nurturer:"+
" Place a great deal of importance on their personal relationships."+
" They're generally very giving and loving people, who place the needs of others above their own."+
" They sometimes have a problem with becoming overly emotionally needy,"+
" and with keeping their true feelings hidden from others. "+
"They take their commitments very seriously, and seek lifelong relationships. "+
"They are extremely dependable, and put forth a lot of energy into keeping things running smoothly."+
" They sometimes have difficulty saying \"no\" when asked to do something, and therefore may be taken for granted.",
"3": "The Caregiver:"+
" are warm-hearted individuals who highly value their close personal relationships."+
" They are very service-oriented, and their own happiness is closely tied into the happiness "+
"and comfort of those around them. They are valued for their genuine warm and caring natures,"+
" and their special ability to bring out the best in others. They usually do not handle conflict well,"+
" and may tend to be very controlling or manipulative. Relationships are central to their lives, "+
"and they put forth a great amount of energy into developing and maintaining their close interpersonal relationships."+
" They expect the same from others",
"4": "The Mechanic:"+
"Generally extremely capable individuals who are good at most things which interest them."+
" They are usually bright, interesting, and exciting individuals with a lot to offer. "+
"They live almost entirely in the present moment, and usually do not make commitments beyond the "+
"immediate foreseeable future. An ISTP probably coined the phrase \"nothing is unconditional\". "+
"They strongly prefer to take things one day at a time, rather than make long-term commitments. "+
"If a relationship interests them and satisfies their needs, the ISTP will do their part on a daily basis"+
" to keep the relationship strong and healthy. If they lose interest in a relationship, "+
"their natural tendency will be to move on.",
"5": "The Performer:"+
"Fun and delightful to be with. They live for the moment, and know how to make the most of each moment. "+
"They are genuinely, warmly interested in people, and love to make others happy. "+
"They're usually very kind-hearted and generous, and are always going out of their way to do "+
"something nice for someone. Their affection is simple, straight-forward and honest. "+
"They dislike theory and complexities. They often resist forming relationships which require them to "+
"function on a high Intuitive or Thinking level. They prefer for things to be light and happy, "+
"although their warmth and affection runs deep. Their potential downfall is the tendency to live "+
"entirely for the present moment, and therefore to sometimes be unaware of the direction that their "+
"relationship is heading, or to be easily distracted from long-term commitments.",
"6": "The Thinker:"+
"live rich worlds inside their minds, which are full of imagination and excitement. "+
"Consequently, they sometimes find the external world pales in comparison. "+
"This may result in a lack of motivation to form and maintain relationships. "+
"They are not likely to have a very large circle of significant relationships in their lives. "+
"They\'re much more likely to have a few very close relationships, which they hold in great esteem "+
"and with great affection. Since their primary focus and attention is turned inwards, "+
"aimed towards seeking clarity from abstract ideas, they are not naturally tuned into others\' "+
"emotional feelings and needs. They tend to be difficult to get to know well, and hold back parts of "+
"themselves until the other person has proven themselves \"worthy\" of hearing the INTP's thoughts. "+
"Holding Knowledge and Brain Power above all else in importance, they will choose to be around "+
"people who they consider to be intelligent. Once they have committed themself to a relationship, "+
"they tend to be very faithful and loyal, and form affectionate attachments which are pure and straight-forward. "+
"The INTP has no interest or understanding of game-playing with regards to relationships. "+
"However, if something happens which they considers irreconciliable, they will leave the relationship "+
"and not look back.",
"7": "The Givers:"+
"Puts a lot of effort and enthusiasm into their relationships. To some extent, "+
"they define themself by the closeness and authenticity of their personal relationships, "+
"and are therefore highly invested in the business of relationships. They have very good people skills, "+
"and are affectionate and considerate. They are warmly affirming and nurturing. "+
"The excel at bringing out the best in others, and warmly supporting them. "+
"They want responding affirmation from their relationships, although they have a problem asking for it. "+
"When a situation calls for it, they will become very sharp and critical. "+
"After having made their point, they will return to their natural, warm selves. "+
"They may have a tendency to \"smother\" their loved ones, but are generally highly valued for "+
"their genuine warmth and caring natures.",
"8": "The Protector:"+
" warm and affirming people who are usually also deep and complex. "+
"They're likely to seek out and promote relationships that are intense and meaningful. "+
"They tend to be perfectionists, and are always striving for the Ultimate Relationship. "+
"For the most part, this is a positive feature, but sometimes works against them if they "+
"fall into the habit of moving from relationship to relationship, always in search of a more perfect partner. "+
"In general, the INFJ is a deeply warm and caring person who is highly invested in the health of "+
"their close relationships, and puts forth a lot of effort to make them positive. They are valued by "+
"those close to them for these special qualities. They seek long-term, lifelong relationships, "+
"although they don't always find them",
"9": "The Idealist:"+
"Present a calm, pleasant face to the world. They appear to be tranquil and peaceful to others, "+
"with simple desires. In fact, they internally feels his or her life intensely. In the relationship arena, "+
"this causes them to have a very deep capacity for love and caring which is not frequently found with such "+
"intensity in the other types. They do not devote their intense feelings towards just anyone, "+
"and are relatively reserved about expressing their inner-most feelings. They reserve their deepest love "+
"and caring for a select few who are closest to them. They are generally laid-back, supportive and nurturing "+
"in their close relationships. With Introverted Feeling dominating their personality, "+
"they're very sensitive and in-tune with people's feelings, and feel genuine concern and caring for others. "+
"Slow to trust others and cautious in the beginning of a relationship, will be fiercely loyal once "+
"they are committed. With their strong inner core of values, they are intense individuals who value depth "+
"and authenticity in their relationships, and hold those who understand and accept the their perspectives "+
"in especially high regard. INFPs are usually adaptable and congenial, unless one of their ruling principles "+
"has been violated, in which case they stop adapting and become staunch defenders of their values. "+
"They will be uncharacteristically harsh and rigid in such a situation."
}
function flamesPredictions(countYou,countPartner){
var total = countYou+countPartner;
var result = Math.abs(total%10);
var $perdiction = $(".flames");
var $perdictiony = $(".perdictionyou");
var $perdictionp = $(".perdictionpartner");
/* console.log(perdictions[countYou]);
console.log(perdictions[countPartner]);
console.log(relationship[result]);*/
$perdiction.text(relationship[result]);
$perdictiony.text(perdictions[countYou]);
$perdictionp.text(perdictions[countPartner]);
}
function trueLoveGame(value){
var nums=[];
var tempnums=[];
for(var i =0; i < value.length;i++){
var count = 0;
for(var a = 0; a < value.length;a++){
//console.log("testing: "+value[a]);
if(value[i] === value[a]){
count++;
}
else{}
}//close loop values a
var letter = value[i];
tempnums[letter] = tempnums[letter] || 0;
tempnums[letter]++;
} //close loop value i
for(var m in tempnums){
nums.push(tempnums[m]);
}
return nums;
}
var tempArray =[];
function mathsetup(myArray){
var result;
if(myArray.length > 1){
result = myArray[0] + myArray[myArray.length-1];
if(result > 9){
var str = result.toString();
//push each into temp
for(var i = 0, len = str.length; i < len; i ++){
var newResult = str.charAt(i);
tempArray.push(+str.charAt(i));
}
} else{
tempArray.push(result);
}
myArray.pop();
myArray.shift();
mathsetup(myArray);
}
else if(myArray.length === 1){
result = myArray[0];
tempArray.push(result);
nextArray(tempArray,myArray);
}else{
nextArray(tempArray,myArray);
}
}
function nextArray(newArray,oldArray){
var returnArray =[];
//push into new array to reset old
for(var i in newArray){
returnArray.push(newArray[i]);
}
tempArray =[];
if (returnArray.length >= 3 && oldArray.length <= 1){
mathsetup(returnArray);
}else{
var value =returnArray[0]+""+returnArray[returnArray.length-1];
$(".score").text(value+"%");
if (value >= 81){
$(".overall").text("Based on the your scored in the love calculator and the Enrich theory your couple is define as the "+brief["0"]);
} else if (value >= 61 && value <= 80){
$(".overall").text(brief["1"]);
} else if (value >= 41 && value <= 60){
$(".overall").text(brief["2"]);
}else if (value >= 21 && value <= 40){
$(".overall").text(brief["3"]);
}else if (value < 20 ){
$(".overall").text(brief["4"]);
}
}
//tabs switch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment