Tactics Sharp – Quick Redesign

Alright I feel kinda stupid now. I didn’t realize I could use an enum like this. Here is what my bitwise operation functions look like now.

        public void promote(CharClass _class)
        {
            if (_class != (this._class & _class))  // - Checks if class is deactive  
                this._class = this._class | _class;  // - Adds state
        }

        public void demote(CharClass _class)
        {
            if (_class == (this._class & _class))   // - Checks if class is active
                this._class = this._class ^ _class; // - Removes state
           
        }


Also, here is what the code looks like on the other end.

static void Main(string[] args)
        {
            Grid gameBoard = new Grid(10, 10);
            Character BitDiddler = new Character("Bit Diddler");
            gameBoard.set(0, 0, BitDiddler, Terrain.blank);

            BitDiddler.promote(CharClass.Archer);
            BitDiddler.promote(CharClass.Knight);
            BitDiddler.promote(CharClass.Mage);
            BitDiddler.promote(CharClass.Monk);
            BitDiddler.promote(CharClass.Theif);
            BitDiddler.lvlUP();

            Console.WriteLine( gameBoard.get(0,0).getChar().toString() );
            Console.WriteLine(gameBoard.get(0, 0).getChar().getState());

            BitDiddler.addState(State.OnFire);
            Console.WriteLine(gameBoard.get(0, 0).getChar().getState());

            gameBoard.get(0, 0).getChar().removeState(State.OnFire);
            Console.WriteLine(gameBoard.get(0, 0).getChar().getState());

            Console.ReadLine();
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s