<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Christian Howard</title>
    <description>The latest articles on DEV Community by Christian Howard (@christianhoward).</description>
    <link>https://dev.to/christianhoward</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F37104%2Fb211d6ff-199e-4cd1-9f68-95f8c4e409fb.jpg</url>
      <title>DEV Community: Christian Howard</title>
      <link>https://dev.to/christianhoward</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/christianhoward"/>
    <language>en</language>
    <item>
      <title>[Entry] Mafia: A Game About Deduction</title>
      <dc:creator>Christian Howard</dc:creator>
      <pubDate>Fri, 25 May 2018 15:25:52 +0000</pubDate>
      <link>https://dev.to/christianhoward/entry-mafia-a-game-about-deduction-3gkm</link>
      <guid>https://dev.to/christianhoward/entry-mafia-a-game-about-deduction-3gkm</guid>
      <description>&lt;h1&gt;
  
  
  What I built
&lt;/h1&gt;

&lt;p&gt;Mafia is an online version of the popular icebreaker/party game with the same name. It is also known as Werewolf to some. In this game, players are divided into two groups, the Mafia and the Villagers. Within the Villagers, there are two special roles, the Doctor and the Detective. The game is played in two phases: Day and Night.&lt;/p&gt;

&lt;p&gt;During the Day phase, the players tries to deduce which players belong to which group and anyone can put a specific player up for public elimination. If a majority vote succeeds, the player is eliminated. During the Night phase, the Mafia can chat to determine which player they want to eliminate while the Doctor can choose one player to save and the Detective can investigate one player to see which group they belong to.&lt;/p&gt;

&lt;p&gt;The game ends when either the Mafia eliminate all the Villagers or the Villagers eliminate the Mafia.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo Link
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://app-mafia-game.herokuapp.com"&gt;https://app-mafia-game.herokuapp.com&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/christianhoward/mafia"&gt;https://github.com/christianhoward/mafia&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How I built it
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Stack&lt;/strong&gt;&lt;br&gt;
React.js&lt;br&gt;
Node.js/Express.js&lt;br&gt;
Pusher&lt;/p&gt;

&lt;p&gt;When I originally thought of this idea, I thought Pusher would only be used for the chat portion and everything else would be pretty straight forward. That was not the case what-so-ever. I should have realized that Pusher would be needed for just about every part of the app and not just the chat. Manually testing a project of this size was also tough to handle. Knowing what I know now, I would probably opt for something less complex for my first go-around with a technology that is new to me (Pusher).&lt;/p&gt;

&lt;h1&gt;
  
  
  Additional Resources/Info
&lt;/h1&gt;

&lt;p&gt;Unfortunately, I encountered a road block in the form of a last minute coding challenge that needed to take priority, so this is no where near being as polished as I would like.&lt;/p&gt;

&lt;p&gt;This game is hard coded for 7 players, so if you are interested in trying it out, I would recommend having 7 total players (including yourself). I also had to hard code the roles for the game, so the role distribution is never randomized. If I had more time, I would have figured out a way to properly randomize the roles. It can be a little finicky at times, but I'm not sure if this is because of my testing locally or if it's the code itself.&lt;/p&gt;

&lt;p&gt;Additionally, there are a few UI bugs in the Mafia Chat that I would have liked to clean up but ran out of time. Styling also fell by the wayside to some extent. Generally, my approach is functionality then styling, so with the time crunch, some styling wasn't completed.&lt;/p&gt;

&lt;p&gt;With more time, I would also figure out some way to encrypt the React state, so that tech savvy players couldn't go into the DevTools and spoil the game haha.&lt;/p&gt;

&lt;h1&gt;
  
  
  Other Posts
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://dev.to/christianhoward/mafia-initial-thoughts-and-moving-forward--3a1o"&gt;Initial Thoughts&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/christianhoward/mafia-feature-building-and-css-distractions-3cm"&gt;Feature Building and CSS Distractions&lt;/a&gt;&lt;/p&gt;

</description>
      <category>pushercontest</category>
      <category>react</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Mafia: Feature Building and CSS Distractions</title>
      <dc:creator>Christian Howard</dc:creator>
      <pubDate>Sat, 19 May 2018 04:31:10 +0000</pubDate>
      <link>https://dev.to/christianhoward/mafia-feature-building-and-css-distractions-3cm</link>
      <guid>https://dev.to/christianhoward/mafia-feature-building-and-css-distractions-3cm</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/christianhoward/mafia-initial-thoughts-and-moving-forward--3a1o"&gt;first post&lt;/a&gt; about my Mafia project, I outlined some thoughts and plans. Since then, I have executed on some of those ideas and gotten distracted by other ideas.&lt;/p&gt;

&lt;h1&gt;
  
  
  Planning
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fipmw9wmudfcygl53qzrc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fipmw9wmudfcygl53qzrc.png" alt="Scrum Board"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, I jumped into Trello and set up a scrum board to track the various parts of my build. I try to breakdown my projects into back-end tasks, front-end tasks, database tasks and deployment tasks. For the most part, most things fall into the front-end portion of this project as most of the Pusher logic falls into that area.&lt;/p&gt;

&lt;h1&gt;
  
  
  Initial Progress
&lt;/h1&gt;

&lt;p&gt;After playing around with Pusher in my sandbox repo, I opted to start a fresh repo and move over pieces of code that I had written to accomplish some of the things I want in this project. After getting everything squared away, I dove into improving the chat by adding styling and admin messages that are announced when players join the game, leave the game or are eliminated from the game. Hopefully players find this helpful once the game is in motion. &lt;/p&gt;

&lt;p&gt;After that, I set forward to build out a &lt;code&gt;PlayerPanel&lt;/code&gt; component to house all the players in the game. This took longer than expected because I had to figure out how to properly update the players array when either you OR other players joined the room. Once I figured that out it was smooth sailing. I was able to write some CSS to manage what a player icon would look like when they are eliminated and I think it looks pretty slick. Following that, I started working on features in the &lt;code&gt;ActionsPanel&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Feature Building
&lt;/h1&gt;

&lt;p&gt;Feature building is one of the best parts about building web apps, because that is where the bulk of the project is! It's also one of the hardest things to test on your own. Initially, I built a generic &lt;code&gt;Button&lt;/code&gt; component that would take in props and be reusable (which is something I had never done in any of my React projects). This led to a lot of refactoring and exploration and rabbit holes. Had this been closer to the deadline, I would have probably cut some corners but I'm happy that it happened at this point in my project.&lt;/p&gt;

&lt;p&gt;After that, I worked on building partial elimination functionality to test my elimination css before diving into a &lt;code&gt;Timer&lt;/code&gt; component for each round. Since all rounds and parts of the round will be timed, it's important for players to have a sense of how long they have. This was pretty straight-forward, as I had built a countdown timer in a previous tutorial project.&lt;/p&gt;

&lt;p&gt;Following that, I jumped into assigning roles randomly to players once the game starts and building out the &lt;code&gt;DoctorsVote&lt;/code&gt; and &lt;code&gt;DetectiveVote&lt;/code&gt; components for those roles to use. The general ideas behind the &lt;code&gt;DetectiveVote&lt;/code&gt; component will apply to some of the other &lt;code&gt;Vote&lt;/code&gt; components, so successfully completing the logic behind that component should accelerate the completion of the other components.&lt;/p&gt;

&lt;p&gt;A lot of my testing and playing around has been by loading the features into the actions panel and just playing around with them. Once I have the &lt;code&gt;playGame&lt;/code&gt; function in place, components will shift in and out of the &lt;code&gt;ActionsPanel&lt;/code&gt; when they are needed. Here is a sneak peak of what that looks like (note that a bunch of css is still in play): &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdvegwzrstnpmc87m8qxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdvegwzrstnpmc87m8qxo.png" alt="Sneak Peak"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note all the random actions I was testing in the &lt;code&gt;ActionsPanel&lt;/code&gt; on the right hand side 😂&lt;/p&gt;

&lt;h1&gt;
  
  
  Gotchas
&lt;/h1&gt;

&lt;p&gt;One of the big gotchas I ran into was the disabled field in my &lt;code&gt;Button&lt;/code&gt; component. I couldn't figure out how to properly pass true/false values into it early on so that once players submitted a vote, they couldn't change it. Once I figured out the proper flow of data through the components, everything seemed to fall into place.&lt;/p&gt;

&lt;p&gt;Also, make sure your routes have the &lt;code&gt;/&lt;/code&gt; in front of them. I spent a half hour trying to debug a 404 issue only to discover that the &lt;code&gt;/&lt;/code&gt; was missing at the beginning of the route lol.&lt;/p&gt;

&lt;h1&gt;
  
  
  Moving Forward
&lt;/h1&gt;

&lt;p&gt;Next steps are continuing to work on the game architecture and hopefully not get too distracted by the css before things are finished. The mindset for the next couple of days is "Build features now, make it pretty later". I know this was pretty vague. I'm happy to go into more detail if anyone has questions or comments!&lt;/p&gt;

</description>
      <category>pushercontest</category>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
    </item>
    <item>
      <title>Mafia: Initial Thoughts and Moving Forward </title>
      <dc:creator>Christian Howard</dc:creator>
      <pubDate>Tue, 15 May 2018 15:19:14 +0000</pubDate>
      <link>https://dev.to/christianhoward/mafia-initial-thoughts-and-moving-forward--3a1o</link>
      <guid>https://dev.to/christianhoward/mafia-initial-thoughts-and-moving-forward--3a1o</guid>
      <description>&lt;p&gt;When I saw the Pusher Contest email land in my inbox a few weeks ago, I saw the opportunity to challenge myself to build a product within a limited timeframe and use a technology that I do not have much experience with. I leapt at the opportunity and started thinking about what I could build and how I would go about doing that. First, I dove into Pusher to really figure out what it does and how it works. &lt;/p&gt;

&lt;h1&gt;
  
  
  First Experience with Pusher
&lt;/h1&gt;

&lt;p&gt;My first thought was to think of building a simple game that implemented a chat feature, so that players could talk to each other. Thus, I started diving into Pusher tutorials to see how to use Pusher Channels to accomplish this. Once I felt I had a good understanding of the data flow, I opted to dive right into some sandbox style tests to see how the rest of the application would work. It was in this sandbox that I discovered that Pusher would be needed not only for the chat aspect, but likely every other aspect as well (but more on that later). With this realization, I discovered that I could definitely implement my idea for a web based version of the game Mafia.&lt;/p&gt;

&lt;h1&gt;
  
  
  Mafia
&lt;/h1&gt;

&lt;p&gt;My Mafia game will be a web based version of the popular icebreaker/party game Mafia (also known as Werewolf in some areas). Users will be able to provide a username and room name to join a room that other players are in. In that room, every player would be able to chat with other players and make decisions based on their role in the game. Once a player is eliminated, they would no longer be able to chat or make decisions that would influence the game.&lt;/p&gt;

&lt;p&gt;For those not familiar with the game, there are two categories a player can be grouped into: Mafia or Villager. Players that are part of the Mafia know who the other members of the Mafia are. Each night, members of the Mafia will eliminate one person from the game. Everyone else is a Villager. Within the group of Villagers, there are two special roles: Doctor and Detective. &lt;/p&gt;

&lt;p&gt;The Doctor has the ability to save one member each turn, including the Doctor, but they can not pick the same player in back to back turns. The Detective has the ability to learn what role a player has each turn. Villagers and Mafia will not know who has these specific roles, and neither the Doctor nor the Detective will know who has the other special role. Whoever is not Mafia, the Doctor or the Detective is a regular villager. They have no special powers but do have the ability to vote whether accused townspeople are Mafia or not. If a vote is held on an individual, all players left in the game will vote and the majority rules.&lt;/p&gt;

&lt;p&gt;The beauty of the game is the art of deduction!&lt;/p&gt;

&lt;h1&gt;
  
  
  Architecture
&lt;/h1&gt;

&lt;p&gt;My strongest skills lie in full stack JavaScript, so this project will be built using React on the front-end and Node/Express on the back-end. Pusher will be providing all the action updates within the application.&lt;/p&gt;

&lt;p&gt;I think the use of React components and state will be incredibly helpful in managing all aspects of the game. I have prior experience building a game in a personal project of mine, and found that managing game elements in the state was incredibly helpful.&lt;/p&gt;

&lt;p&gt;My initial wireframe has the game laid out in three areas, a Players Panel to show all the players in the game, a Chat Panel to show the conversation throughout the game, and an Actions Panel to execute the various actions throughout the game.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fyvxwhvutyz44expy12m7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fyvxwhvutyz44expy12m7.png" alt="Mafia wireframe"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my next post, I hope to share my progress, including hiccups and gotchas.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part 2: &lt;a href="https://dev.to/christianhoward/mafia-feature-building-and-css-distractions-3cm"&gt;Feature Building and CSS Distractions&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>pushercontest</category>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
    </item>
  </channel>
</rss>
