<repo_name>ifricker/ifricker.github.io<file_sep>/game.js
 // Design Basic Game Solo Challenge

// This is a solo challenge

// Your mission description:
// Overall mission:  Create a simple Casino War simulator
// Goals: Create simple card game
// Characters: Ask user for input using prompt, alert, and confirm
// Objects: deck of cards, player hand, dealer hand, and bank
// Functions: random card, compare to dealer

// Pseudocode
/*
Instruct the user of the rules of the game
create a deck of cards, 4 suits, 13 ranks
create function that creates a hand
set user bank to 1000
ask user what the want to bet and set to value
reveal user card and ask if they want to play the hand
if not hand is over
if they do show dealer hand
if win add bet to user bank
if loss subract bet to user bank
*/

// Initial Code

// Instructions

alert("\nWelcome to Ian\'s Casino War\n\nYou first place your bet and receive your card.\nYou than can double your bet if you like your card. \nOr you can fold to live another day.\nIf there is a tie, new hand will be played.\nYou will start with 1,000 tokens.\n\nGood luck!\n")

// Create 52 card deck

var deck = [];
// var suit = ["Spades", "Diamnods", "Clubs", "Hearts"]
var suit = ["\u2660","\u2661","\u2662","\u2663"];
// var rank = ["2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"];
var rank = ["2","3","4","5","6","7","8","9","T","J","Q","K","A"]
suit.forEach(function (suit){
  rank.forEach(function (rank) {
    deck.push(rank + suit);
  });
});
// console.log(deck);

// Create a hand(may be more complicated, was originally going to make a 3 card poker game but did not want to write all of the arguments for what hands beat what)

function createHand(){
  var hand = [];
  for (var i = 0; i <= 0; i += 1) {
      hand.push(deck.splice(Math.floor(Math.random() * deck.length), 1));
  };
  hand = hand.join(" ");
  return hand
};


// Create user tokens, create player object and dealer object.

var player = new Object();
player.token = 1000;
var dealer = new Object();
function bank(){
  return "Player tokens: " + player.token.toString();
};

// Ask player if they want to play again

function playAgain() {
  var again = confirm("Do you want to play again?");
  if (again == false) {
    alert("Thank you for playing.  You finished with " + player.token + " tokens!")
  };
  if (again == true) {
    playWar();
  };
};

// Play game

function playWar(){
  player.hand = createHand();
  dealer.hand = createHand();
  var bet = Number(prompt(bank() + "\nPlayer wager: "));
  var play = confirm(bank() + "\nWager is " +bet +"\nDo you want to double your bet and play?\nOr do you want to surrender and forfeit your wager?\n" + "Player hand: " + player.hand);
    if (play == false) {
      player.token = player.token - bet
      alert(bank());
      playAgain();
    };
    if (play == true) {
      if (player.hand[0] == dealer.hand[0]) {
        alert("Player Hand: " + player.hand + "\nDealer Hand: " + dealer.hand + "\nIt's a tie!\n" + bank())
        playAgain();
      };
      if (rank.indexOf(player.hand[0]) > rank.indexOf(dealer.hand[0])) {
        player.token = player.token + (bet*2)
        alert("Player Hand: " + player.hand + "\nDealer Hand: " + dealer.hand + "\nYou win " + (bet*2).toString() + " tokens!\n" + bank())
        playAgain();
      };
      if (rank.indexOf(player.hand[0]) < rank.indexOf(dealer.hand[0])) {
        player.token = player.token - (bet*2)
        alert("Player Hand: " + player.hand + "\nDealer Hand: " + dealer.hand + "\nYou lose " + (bet*2).toString() + " tokens!\n" + bank())
        playAgain();
    };
  };
};

// Run game

playWar();


// Reflection
/*
What was the most difficult part of this challenge?
    At first I wanted to make a three card poker game or a pia gow until I realised I would have to created a list of every hand to be able to compair to the dealer.  I switch to making my own version of caisno war.  After running many test I was able to make the game do what I think is a decent version of war.  The next issue I had was trying to make the game play on my website.  I still have a lot to learn and after trying a few things I had to settle for the game to play with pop ups.
What did you learn about creating objects and functions that interact with one another?
    After making my game I realised that I did not make any properties.  I can make them for the user to will hold his card and his bank.  I will do this if I have enough time.  I created functions that call upon each other.  Very similar to classes in ruby.
Did you learn about any new built-in methods you could use in your refactored solution? If so, what were they and how do they work?
    I still wish the built in methods were more automatic for me but that will come with time.  Overall the game is pretty simple.
How can you access and manipulate properties of objects?
    You can call upon them with a period or bracket.
*/<file_sep>/blog/enumerable-methods.html
<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="Blog Enumerable Partition">
  <title>Blog | Enumerable.partition Equals What?</title>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="../stylesheets/default.css">
  <link rel="stylesheet" type="text/css" href="../stylesheets/blog.css">
  <meta name="author" content="<NAME>">
</head>
  <body>
    <nav class="navbar">
      <div id="nav-left">
        <a href="http://ifricker.github.io/">Ian <span class="heavy">Fricker</span></a>
      </div>
      <div id="nav-right">
        <a href="http://ifricker.github.io/#aboutme">About Me</a>
        <a href="http://ifricker.github.io/#experience">Experience</a>
        <a href="http://ifricker.github.io/#education">Education</a>
        <a href="http://ifricker.github.io/#projects">Projects</a>
        <a href="http://ifricker.github.io/blog">Blog</a>
        <a href="http://ifricker.github.io/#contact">Contact</a>
      </div>
    </nav>
    <div class="blog-post">
      <div class="blog-entry">
        <p id="blog-title">Enumerable.partition Equals What?</p>
        <p id="blog-date">January 31, 2016</p>
        <p id="blog-author">By <NAME></p>
        <p id="blog-subtitle">How to work with partition</p>
        <p id="blog-paragraph">So what is an enumerable anyway?  An enumerable is a module that iterates over a collection and does whatever method you call upon it.  It that sense it is very similar to <code>.each</code>.  Some enumerable examples include <code>map</code>, <code>select</code>, <code>inject</code>, <code>any?</code>, <code>sort</code>, and <code>sort_by</code>, to name a few.</p>
        <p id="blog-paragraph">I'm going to discuss an enumerable that I just learned that helped me complete my most recent assignment.  This assignment had an input of an array that included both strings and integers.  The output was to split this array and put all of the numbers into its own array and strings in another after.  After doing some research I found <code>partition</code>.</p>
        <br>
        <p><code>array = ["red", "blue", 4, "banana", 14, "grapes", 6]</code><br><br><code>def split(source)</code><br><code><pre>  strings, nums = source.partition {|x| x.is_a? String}</pre></code><code><pre>  result = [nums] + [strings]</pre></code><code>end</code><br><br><code>split(array)</code><br><code>=> [[4, 14, 6], ["red", "blue", "banana", "grapes"]]</code></p>
        <br>
        <p id="blog-paragraph">In the example above you can see that I was given the array that includes some colors, numbers and even fruits.  I called the partition method.  I set two variables on the left side of the equal sign to strings, and nums.  In the <code>.partition</code> method I have it looking at each item and seeing if it is a string with the <code>.is_a? String</code> method.  If the argument is true it places the item in the array to the first variable.  If the argument is false it places it into the second.</p>
        <p id="blog-paragraph">Visit the Ruby Docs to find out all of the enumerables that exist.  You will find them to make your coding more readable, shorter, and simpler.  </p>
      </div>
      <div id="previous-button">
        <a href="./online-security.html" id="resume-button">Previous</a>
      </div>
      <div id="next-button">
        <a href="./index.html" id="resume-button">Next</a>
      </div>
    </div>
  <footer class="footbar">
    <a href="mailto:<EMAIL>"><img src="../imgs/email-white.png" onmouseover="this.src='../imgs/email-color.png'" onmouseout="this.src='../imgs/email-white.png'" alt="email" class="icon-style"></a>
    <a href="https://www.linkedin.com/in/ianfricker"><img src="../imgs/linkedin-white.png" onmouseover="this.src='../imgs/linkedin-color.png'" onmouseout="this.src='../imgs/linkedin-white.png'" alt="linkedin" class="icon-style"></a>
    <a href="https://github.com/ifricker"><img src="../imgs/github-white.png" onmouseover="this.src='../imgs/github-color.png'" onmouseout="this.src='../imgs/github-white.png'" alt="github" class="icon-style"></a>
    <a href="https://www.instagram.com/ifricker/"><img src="../imgs/instagram-white.png" onmouseover="this.src='../imgs/instagram-color.png'" onmouseout="this.src='../imgs/instagram-white.png'" alt="instagram" class="icon-style"></a>
    <h4>Copyright &copy; <NAME> 2016</h4>
  </footer>
  </body>
</html><file_sep>/reflection.md
## 3.5 Your Website, Part 3

#### What did you learn about CSS padding, borders, and margin by doing this challenge?
Padding, borders, and margins are very important to developing the website's space.  Margins is the blank space you want around your content.  Borders are if you want some sore of style on the outside of the content. Padding is used to move content to where you want it on the page.

#### What did you learn about CSS positioning?
I learned that you need to take it one step at a time.  I found myself not breaking it down to each area that I wanted on the page and had to go back to adjust things.  You need to start with the overall size and then move to the content on the page.

#### What aspects of your design did you find easiest to implement? What was most difficult?
The easiest for me was probably to setup text fonts, text colors, and designing links.  The most difficult was the overall spacing of different sections on the page.

#### What did you learn about adding and formatting elements with CSS in this challenge?
I learned a lot about formatting.  At first I didn't really know the difference on when to use a class vs an ID.  I was making redundant classes when you could use the same one as before.  Overall its just getting comfortable with the spacing on the page.<file_sep>/README.md
# ifricker.github.io
