<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using _2HourGame.Model;
using _2HourGame.View;

namespace _2HourGame.Controller
{
    static class ShipControllBehaviours
    {
        public static void FireCannons(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime) 
        {
            if (gs.IsButtonDown(Buttons.LeftTrigger))
            {
                player.FireCannon(gameTime, CannonType.LeftCannon);
            }
            if (gs.IsButtonDown(Buttons.RightTrigger))
            {
                player.FireCannon(gameTime, CannonType.RightCannon);
            }
        }

        public static void PickupGold(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime) 
        {
            if (gs.IsButtonDown(Buttons.A) && previousGamePadState.IsButtonUp(Buttons.A)) 
            {
                player.AttemptPickupGold(gameTime);
            }
        }

        public static void RepairShip(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime) 
        {
            if (gs.IsButtonDown(Buttons.B) && previousGamePadState.IsButtonUp(Buttons.B))
                player.AttemptRepair();
        }
    }
}<commit_msg>Controller keys can now be mapped to actions.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

using _2HourGame.Model;
using _2HourGame.View;

namespace _2HourGame.Controller
{
    static class ShipControllBehaviours
    {
        public enum Action { FireLeftCannon, FireRightCannon, PickupGold, RepairShip };

        static Dictionary<Action, Buttons> actionKeys;

        static ShipControllBehaviours()
        {
            actionKeys = new Dictionary<Action, Buttons>();

            actionKeys.Add(Action.FireLeftCannon, Buttons.LeftTrigger);
            actionKeys.Add(Action.FireRightCannon, Buttons.RightTrigger);
            actionKeys.Add(Action.PickupGold, Buttons.A);
            actionKeys.Add(Action.RepairShip, Buttons.B);
        }


        public static void FireCannons(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime)
        {
            if (gs.IsButtonDown(actionKeys[Action.FireLeftCannon]))
            {
                player.FireCannon(gameTime, CannonType.LeftCannon);
            }
            if (gs.IsButtonDown(actionKeys[Action.FireRightCannon]))
            {
                player.FireCannon(gameTime, CannonType.RightCannon);
            }
        }

        public static void PickupGold(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime)
        {
            var pickupGoldButton = actionKeys[Action.PickupGold];
            if (gs.IsButtonDown(pickupGoldButton) && previousGamePadState.IsButtonUp(pickupGoldButton))
            {
                player.AttemptPickupGold(gameTime);
            }
        }

        public static void RepairShip(GamePadState gs, GamePadState previousGamePadState, Player player, GameTime gameTime)
        {
            var repairButton = actionKeys[Action.RepairShip];
            if (gs.IsButtonDown(repairButton) && previousGamePadState.IsButtonUp(repairButton))
                player.AttemptRepair();
        }
    }
}
{'fraction_non_alphanumeric': 0.0816917728852839, 'fraction_numerical': 0.0017381228273464658, 'mean_word_length': 2.5671487603305785, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2768', 'n_tokens_mistral': 980, 'n_tokens_neox': 957, 'n_words': 178}