text:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package src.model.constructs;

import java.util.ArrayList;
import java.util.Random;

import src.Effect;
import src.FacingDirection;
import src.Key_Commands;
import src.SkillEnum;
import src.io.view.display.Display;
import src.model.MapEntity_Relation;
import src.model.constructs.items.EquipableItem;
import src.model.constructs.items.Item;
import src.model.constructs.items.OneHandedWeapon;
import src.model.constructs.items.PickupableItem;
import src.model.constructs.items.PrimaryHandHoldable;
import src.model.constructs.items.SecondaryHandHoldable;
import src.model.constructs.items.Shield;
import src.model.constructs.items.TwoHandedWeapon;

/**
 * Entity inherits from DrawableThing. Entity is a DrawableThing that can move
 * on the map.
 */
abstract public class Entity extends DrawableThing {

    private PrimaryHandHoldable primary_hand_ = null;
    private SecondaryHandHoldable secondary_hand_ = null;
    private FacingDirection direction_ = FacingDirection.UP;
    private ArrayList<PickupableItem> inventory_;
    private EntityStatsPack stats_pack_ = new EntityStatsPack();
    private int num_gold_coins_when_spawned_ = 10;
    private int num_gold_coins_possessed_ = num_gold_coins_when_spawned_;
    private String observation_string = "";

    public String getObservationString() {
        return observation_string;
    }

    private boolean has_lives_left_ = true;

    /**
     *
     * @return true if you have lives left, false if you don't.
     */
    public boolean hasLivesLeft() {
        return has_lives_left_;
    }

    /**
     * Entity Constructor
     *
     * @param name
     * @param representation - What will represent the Entity on the screen.
     */
    public Entity(String name, char representation) {
        super(name, representation);
        inventory_ = new ArrayList<PickupableItem>();
    }

    public int getNumGoldCoins() {
        return num_gold_coins_possessed_;
    }

    protected void setNumGoldCoinsWhenSpawned(int amount) {
        num_gold_coins_when_spawned_ = amount;
    }

    /**
     * Reset the num_gold_coins to the original amount. Used after re-spawning.
     *
     * @author John-Michael Reed
     */
    public void reinstateNumGoldCoins() {
        num_gold_coins_possessed_ = num_gold_coins_when_spawned_;
    }

    public int decrementNumGoldCoinsBy(int amount) {
        num_gold_coins_possessed_ -= amount;
        if (num_gold_coins_possessed_ >= 0) {
            return num_gold_coins_possessed_;
        } else {
            System.err.println("Number of coins going negative in Entity.decrementNumGoldCoinsBy(int amount)");
            num_gold_coins_possessed_ = 0;
            return num_gold_coins_possessed_;
        }
    }

    public int incrementNumGoldCoinsBy(int amount) {
        return (num_gold_coins_possessed_ += amount);
    }

    public abstract ArrayList<String> getInteractionOptionStrings();

    public abstract ArrayList<String> getConversationStarterStrings();

    /**
     * This function returns a list of appropriate responses to the string that
     * you recieved last.
     *
     * @author John-Michael Reed
     * @param what_you_just_said_to_me - same as "what you last said to me"
     * @return conversation options
     */
    public abstract ArrayList<String> getConversationContinuationStrings(String what_you_just_said_to_me, Entity who_is_talking_to_me);

    public abstract ArrayList<String> getListOfItemsYouCanUseOnMe();

    public int getExperienceBetweenLevels() {
        if (stats_pack_ != null) {
            return stats_pack_.NUMBER_OF_EXPERIENCE_POINT_PER_LEVEL;
        } else {
            return -1;
        }
    }

    public FacingDirection getFacingDirection() {
        return direction_;
    }

    public void setFacingDirection(FacingDirection dir) {
        direction_ = dir;
    }

    public ArrayList<PickupableItem> getInventory() {
        return this.inventory_;
    }

    private ArrayList<String> said_to_me_ = new ArrayList<String>();

    public void sayStuffToMe(ArrayList<String> in) {
        for (String i : in) {
            said_to_me_.add(i);
        }

    }

    // map_relationship_ is used in place of a map_referance_
    private int num_skillpoints_ = 1;

    public int getNum_skillpoints_() {
        return num_skillpoints_;
    }

    public void setSkillPoints(int newPoints) {
        num_skillpoints_ = newPoints;
    }

    // Non-occupation specific skills
    private int bind_wounds_ = 1;

    public int getBind_wounds_() {
        return bind_wounds_;
    }

    public void setBind_wounds_(int value) {
        if (value > 0) {
            bind_wounds_ = value;
        }
    }

    public int bindWounds() {
        this.getMapRelation().areaEffectFunctor.effectAreaWithinRadius(1, getBind_wounds_() + 1, Effect.HEAL);
        return 0;
    }

    private int bargain_ = 1;

    public int getBargain_() {
        return bargain_;
    }

    public void setBargain_(int value) {
        if (value > 0) {
            bargain_ = value;
        }
    }

    private int observation_ = 1;

    public int getObservation_() {
        return observation_;
    }

    public void setObservation_(int value) {
        if (value > 0) {
            observation_ = value;
        }
    }

    /**
     * Gets information based on observation level. If the entity is facing up,
     * observation will work in the up direction.
     *
     * @author Reid Olsen
     * @return
     */
    public int observe() {
        observation_string = "";
        Random rn = new Random();

        String s = "";

        // Get random number between 0 and 10.
        int chanceForSuccessfulObserve = rn.nextInt(11);
        // Checks if observe is succuessful, takes observation level into
        // account. If observation level is 11 or higher, success rate is %100.
        if (chanceForSuccessfulObserve >= (11 - observation_)) {
            observation_string
                    += "Looking in direction: " + getFacingDirection() + "\n";

            if (getFacingDirection() == FacingDirection.UP) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo(0, (i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.UP_RIGHT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo((i + 1), (i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.RIGHT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo((i + 1), 0);
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.DOWN_RIGHT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo((i + 1), -(i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.DOWN) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo(0, -(i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.DOWN_LEFT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo(-(i + 1), -(i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.LEFT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo(-(i + 1), 0);
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            } else if (getFacingDirection() == FacingDirection.UP_LEFT) {
                for (int i = 0; i < observation_; ++i) {
                    s += " Tile " + (i + 1) + ": ";
                    try {
                        s += map_relationship_.getTileInfo(-(i + 1), (i + 1));
                        s += "\n";
                    } catch (NullPointerException e) {
                        s += "No tile here.\n";
                    }
                }
                observation_string += s + "\n";
            }
            return 0;
        } else {
            observation_string += "Failed to look in direction: " + getFacingDirection() + "\n";
            return -1;
        }
    }

    /**
     * Designates a skill point towards a skill.
     *
     * @author John-Michael Reed
     * @param skill
     * @return -2 if no skill points, -1 if skill cannot be spent [invalid
     * occupation]
     */
    public int spendSkillpointOn(SkillEnum skill) {
        if (num_skillpoints_ <= 0) {
            return -2;
        }
        Occupation occupation = this.getOccupation();
        switch (skill) {
            case BIND_WOUNDS:
                ++bind_wounds_;
                --num_skillpoints_;
                return 0;
            case BARGAIN:
                ++bargain_;
                --num_skillpoints_;
                return 0;
            case OBSERVATION:
                ++observation_;
                --num_skillpoints_;
                return 0;
            case OCCUPATION_SKILL_1:
                if (occupation == null) {
                    return -1;
                }
                int error_code = occupation.incrementSkill(skill);
                if (error_code == 0) {
                    --num_skillpoints_;
                }
                return error_code;
            case OCCUPATION_SKILL_2:
                if (occupation == null) {
                    return -1;
                }
                int error_code2 = occupation.incrementSkill(skill);
                if (error_code2 == 0) {
                    --num_skillpoints_;
                }
                return error_code2;
            case OCCUPATION_SKILL_3:
                if (occupation == null) {
                    return -1;
                }
                int error_code3 = occupation.incrementSkill(skill);
                if (error_code3 == 0) {
                    --num_skillpoints_;
                }
                return error_code3;
            case OCCUPATION_SKILL_4:
                if (occupation == null) {
                    return -1;
                }
                int error_code4 = occupation.incrementSkill(skill);
                if (error_code4 == 0) {
                    --num_skillpoints_;
                }
                return error_code4;
            default:
                System.exit(-1); // should never happen
                return -3;
        }
    }

    /**
     * Accepts a key command from the map
     *
     * @param command
     * @param optional_text - either the last thing that was said to you or the
     * thing you are about to say.
     * @return ArrayList of strings for IO_Bundle or null if nothing to display
     */
    public ArrayList<String> acceptKeyCommand(Key_Commands command, String optional_text) {
        MapEntity_Relation mar = this.getMapRelation();
        if (mar == null) {
            System.out
                    .println(this.name_ + " cannot be controlled without a MapAvatar_Relation");
            System.exit(-8);
        }
        Entity target = this.getMapRelation().getEntityInFacingDirection();
        Item target_item_ = this.getMapRelation().getTopmostItemInFacingDirection();
        switch (command) {
            case MOVE_DOWNLEFT:// Move SW
                mar.moveInDirection(-1, -1);
                break;
            case MOVE_DOWN:// Move S
                mar.moveInDirection(0, -1);
                break;
            case MOVE_DOWNRIGHT:// Move SE
                mar.moveInDirection(1, -1);
                break;
            case MOVE_LEFT: // Move W
                mar.moveInDirection(-1, 0);
                break;
            case MOVE_RIGHT:// Move E
                mar.moveInDirection(1, 0);
                break;
            case MOVE_UPLEFT:// Move NW
                mar.moveInDirection(-1, 1);
                break;
            case MOVE_UP:// Move N
                mar.moveInDirection(0, 1);
                break;
            case MOVE_UPRIGHT: // Move NE
                mar.moveInDirection(1, 1);
                break;
            case SAVE_GAME: // Save Game
                // RunGame.saveGameToDisk(); // TODO: this is for testing, remove for
                // deployment
                break;
            case USE_LAST_ITEM: // Use item in inventory
                int error_code = this.useItemInFacingDirectionOnMyself();
                //if(error_code != 0) {
                PickupableItem last = this.getLastItemInInventory();
                if (last == null) {
                    System.out.println("last inventory item is null");
                } else {
                    System.out.println("last inventory item is not null");
                    if (error_code != 0) {
                        last.use(this);
                        System.out.println("using item!");
                    }
                }
                break;
            case EQUIP_LAST_ITEM: // equipMyselfTo
                try {
                    EquipableItem item = (EquipableItem) this.getLastItemInInventory();
                    if (item != null) {
                        Display.getDisplay().setMessage("Attempted to Equip " + item.toString());
                    } else {
                        Display.getDisplay().setMessage("No item(s) to equip");
                    }
                    if (item != null) {
                        item.equipMyselfTo(this);
                        break;
                    }
                } catch (ClassCastException e) {
                    // ignore it
                    Display.getDisplay().setMessage("Cannot Equip From Inventory");
                }
                break;
            case UNEQUIP_EVERYTHING: // unEquip
                this.unEquipEverything();
                Display.getDisplay().setMessage("Unequipped Everything");
                break;
            case DROP_LAST_ITEM: // drop item
                mar.dropItem();
                break;
            case BECOME_SMASHER: // switch to Smasher
                this.becomeSmasher();
                if (occupation_ != null) {
                    this.setRepresentation(occupation_.getOccupationRepresentation());
                }
                break;
            case SWAP_SUB_OCCUPATION://Switch to next in the sub occupations
                this.swapSubClass();
                if (occupation_ != null) {
                    this.setRepresentation(occupation_.getOccupationRepresentation());
                }
                break;
            case BECOME_SUMMONER: // switch to Summoner
                this.becomeSummoner();
                if (occupation_ != null) {
                    this.setRepresentation(occupation_.getOccupationRepresentation());
                }
                break;
            case BECOME_SNEAK: // switch to Sneaker
                this.becomeSneak();
                if (occupation_ != null) {
                    this.setRepresentation(occupation_.getOccupationRepresentation());
                }
                break;
            case BIND_WOUNDS:
                this.bindWounds();
                break;
            case BARGAIN_AND_BARTER:
                if (target != null) {
                    sayStuffToMe(target.getInteractionOptionStrings());
                    break;
                } else {
                    break;
                }
            case OBSERVE:
                this.observe();
                break;
            case USE_SKILL_1:
                if (this.getOccupation() != null) {
                    this.getOccupation().performOccupationSkill(1);
                }
                break;
            case USE_SKILL_2:
                if (this.getOccupation() != null) {
                    this.getOccupation().performOccupationSkill(2);
                }
                break;
            case USE_SKILL_3:
                if (this.getOccupation() != null) {
                    this.getOccupation().performOccupationSkill(3);
                }
                break;
            case USE_SKILL_4:
                if (this.getOccupation() != null) {
                    this.getOccupation().performOccupationSkill(4);
                }
                break;
            case INCREMENT_BIND:
                this.spendSkillpointOn(SkillEnum.BIND_WOUNDS);
                break;
            case INCREMENT_BARGAIN:
                this.spendSkillpointOn(SkillEnum.BARGAIN);
                break;
            case INCREMENT_OBSERVE:
                this.spendSkillpointOn(SkillEnum.OBSERVATION);
                break;
            case INCREMENT_SKILL_1:
                this.spendSkillpointOn(SkillEnum.OCCUPATION_SKILL_1);
                break;
            case INCREMENT_SKILL_2:
                this.spendSkillpointOn(SkillEnum.OCCUPATION_SKILL_2);
                break;
            case INCREMENT_SKILL_3:
                this.spendSkillpointOn(SkillEnum.OCCUPATION_SKILL_3);
                break;
            case INCREMENT_SKILL_4:
                this.spendSkillpointOn(SkillEnum.OCCUPATION_SKILL_4);
                break;
            case GET_INTERACTION_OPTIONS:
                if (target != null) {
                    sayStuffToMe(target.getInteractionOptionStrings());
                    break;
                }
                if (target_item_ != null) {
                    sayStuffToMe(target_item_.getInteractionOptionStrings());
                    break;
                }
                return null;

            case GET_CONVERSATION_STARTERS:
                if (target != null) {
                    return target.getConversationStarterStrings();
                }
                break;
            case GET_CONVERSATION_OPTIONS:
                if (target != null) {
                    sayStuffToMe(target.getConversationContinuationStrings(optional_text, this));
                    break;
                } else if (target_item_ != null) {
                    System.out.println("optional text in Item GET_CONVERSATION_CONTINUATION_OPTIONS: \n" + optional_text);
                    sayStuffToMe(target_item_.getConversationContinuationStrings(optional_text, this));
                    break;
                } else {
                    break;
                }
            case ATTACK:
                getMapRelation().sendAttackInFacingDirection();
                break;
            case DO_ABSOLUTELY_NOTHING:
                break;
            default:
                System.out.println("Invalid command sent to avatar");
                break;
        }
        if (said_to_me_.size() != 0) {
            ArrayList<String> result = said_to_me_;
            said_to_me_ = new ArrayList<String>();
            return result;
        } else {
            return null;
        }
    }

    /**
     * Include stat increase from item i.e., item with stat increase is equipped
     *
     * @param item
     */
    private void addItemStatsToMyStats(Item item) {
        stats_pack_.addOn(item.getStatsPack());
    }

    /**
     * Entities must check their health after they are damaged.
     *
     * @return true if alive false is dead
     */
    public boolean checkHealthAndCommitSuicideIfDead() {
        if (stats_pack_.getCurrent_life_() > 0) {
            return true;
        } else {
            commitSuicide();
            return false;
        }
    }

    /**
     * Entity dies, Game Over.
     */
    public void commitSuicide() {
        int health_left = stats_pack_.getCurrent_life_();
        stats_pack_.deductCurrentLifeBy(health_left);
        stats_pack_.decreaseLivesLeftByOne();
        getMapRelation().respawn();
        if (stats_pack_.getLives_left_() < 0) {
            gameOver();
        }
    }

    public void gameOver() {
        System.out.println("Entity " + this.name_ + " has run out of lives and is gone forever.");
        this.has_lives_left_ = false;
        getMapRelation().removeMyselfFromTheMapCompletely();
    }

    public PrimaryHandHoldable getPrimaryEquipped() {
        return primary_hand_;
    }

    public SecondaryHandHoldable getSecondaryEquipped() {
        return secondary_hand_;
    }

    public void setPrimaryEquipped(PrimaryHandHoldable primary_hard) {
        primary_hand_ = primary_hard;
    }

    public void setSecondaryEquipped(SecondaryHandHoldable secondary_hard) {
        secondary_hand_ = secondary_hard;
    }

    /**
     * @author John-Michael Reed
     * @return
     */
    public int equip(EquipableItem item) {
        int temp = item.equipMyselfTo(this);
        return temp;

    }

    /**
     * @author John-Michael Reed
     * @param shield
     * @return
     */
    public int equipShield(Shield shield) {
        if (shield != null) {
            // In the case of a 2H sword
            if ((primary_hand_ == secondary_hand_) && (secondary_hand_ != null)) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(secondary_hand_.getStatsPack());
                primary_hand_ = null;
                secondary_hand_ = null;
            } // In the case of a shield
            else if ((primary_hand_ != secondary_hand_) && (secondary_hand_ != null)) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(secondary_hand_.getStatsPack());
                secondary_hand_ = null;
            }

            secondary_hand_ = shield;
            stats_pack_.addOn(secondary_hand_.getStatsPack());
            boolean successful_removal = inventory_.remove((PickupableItem) shield);
            if (successful_removal != true) {
                System.exit(-66);
            }
            return 0;
        } else {
            return -5;
        }
    }

    /**
     * @author John-Michael Reed Equips the weapon and modifies stats
     * @param one_hand_weapon
     * @return
     */
    public int equip1hWeapon(final OneHandedWeapon one_hand_weapon) {
        if (one_hand_weapon != null) {
            // In the case of a 2H sword
            if ((primary_hand_ == secondary_hand_) && (primary_hand_ != null)) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(primary_hand_.getStatsPack());
                primary_hand_ = null;
                secondary_hand_ = null;
            } // In the case of a 1h sword
            else if ((primary_hand_ != secondary_hand_) && (primary_hand_ != null)) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(primary_hand_.getStatsPack());
                primary_hand_ = null;
            }

            int error_code = -1; // by default null occupation cannot equipMyselfTo any weapon
            if (occupation_ != null) {
                error_code = occupation_.equipOneHandWeapon(one_hand_weapon);
            }
            if (error_code == 0) {
                primary_hand_ = one_hand_weapon;
                stats_pack_.addOn(primary_hand_.getStatsPack());
                boolean successful_removal = inventory_.remove((PickupableItem) one_hand_weapon);
                if (successful_removal != true) {
                    System.exit(-77);
                }
                return 0;
            } else {
                return error_code;
            }
        } else {
            return -5;
        }
    }

    /**
     * @author John-Michael Reed
     * @param two_hand_weapon
     * @return
     */
    public int equip2hWeapon(TwoHandedWeapon two_hand_weapon) {
        if (two_hand_weapon != null) {
            // case of 2H sword
            if ((primary_hand_ == secondary_hand_) && (primary_hand_ != null)) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(primary_hand_.getStatsPack());
                primary_hand_ = null;
                secondary_hand_ = null;
            } else if ((primary_hand_ != secondary_hand_)) {
                // case of 1h SWORD
                if (primary_hand_ != null) {
                    inventory_.add((PickupableItem) primary_hand_);
                    stats_pack_.reduceBy(primary_hand_.getStatsPack());
                    primary_hand_ = null;
                }
                // case of sheld
                if (secondary_hand_ != null) {
                    inventory_.add((PickupableItem) secondary_hand_);
                    stats_pack_.reduceBy(secondary_hand_.getStatsPack());
                    secondary_hand_ = null;
                }
            }
            primary_hand_ = null;
            secondary_hand_ = null;

            int error_code = -1; // by default null occupation cannot equipMyselfTo any weapon
            if (occupation_ != null) {
                error_code = occupation_.equipTwoHandWeapon(two_hand_weapon);
            }
            if (error_code == 0) {
                primary_hand_ = two_hand_weapon;
                secondary_hand_ = two_hand_weapon;
                stats_pack_.addOn(primary_hand_.getStatsPack());
                boolean successful_removal = inventory_.remove((PickupableItem) two_hand_weapon);
                if (successful_removal != true) {
                    System.exit(-88);
                }
                return 0;
            } else {
                return error_code;
            }
        } else {
            return -5;
        }
    }

    public int unEquipEverything() {
        if (primary_hand_ == secondary_hand_ && primary_hand_ != null) {
            inventory_.add((PickupableItem) primary_hand_);
            stats_pack_.reduceBy(primary_hand_.getStatsPack());
        } else if (primary_hand_ != secondary_hand_) {
            if (primary_hand_ != null) {
                inventory_.add((PickupableItem) primary_hand_);
                stats_pack_.reduceBy(primary_hand_.getStatsPack());
            }
            if (secondary_hand_ != null) {
                inventory_.add((PickupableItem) secondary_hand_);
                stats_pack_.reduceBy(secondary_hand_.getStatsPack());
            }
        }
        primary_hand_ = null;
        secondary_hand_ = null;

        if (occupation_ != null) {
            return occupation_.unEquipEverything();
        } else {
            return 0;
        }
    }

    /**
     * this function levels up an entity Modified to make it "gain enough
     * experience to level up"
     *
     * @author John
     */
    public void gainEnoughExperienceTolevelUp() {
        final int number_of_experience_points_per_level = getExperienceBetweenLevels();
        int exp_to_next = number_of_experience_points_per_level
                - (stats_pack_.getQuantity_of_experience_() % number_of_experience_points_per_level);
        int old_level = stats_pack_.getCached_current_level_();
        gainExperiencePoints(exp_to_next);
        int new_level = stats_pack_.getCached_current_level_();
        if (new_level - old_level != 1) {
            System.err.println("Error in Entity.gainEnoughExperienceTolevelUp()");
            System.exit(-45);
        }

    }

    public boolean hasEquippedPrimaryHand() {
        if (primary_hand_ != null) {
            return true;
        }
        return false;
    }

    public boolean hasEquippedSecondaryHand() {
        if (secondary_hand_ != null) {
            return true;
        }
        return false;
    }

    /**
     * Returns false because Entities are not passable.
     */
    @Override
    public boolean isPassable() {
        return false;
    }

    /**
     * Add item to the inventory.
     *
     * @param item
     */
    public void addItemToInventory(PickupableItem item) {
        inventory_.add(item);
    }

    /**
     * Returns first Item object in Inventory
     *
     * @return Item
     */
    public PickupableItem getLastItemInInventory() {
        if (!inventory_.isEmpty()) {
            return inventory_.get(inventory_.size() - 1);
        } else {
            return null;
        }
    }

    /**
     * Gets last Item in Inventory. In the 0 position of the arrayList.
     *
     * @return Null if list is empty
     */
    public PickupableItem pullLastItemOutOfInventory() {
        if (!inventory_.isEmpty()) {
            return inventory_.remove(inventory_.size() - 1);
        } else {
            return null;
        }
    }

    /**
     * Sends an attack to an entity.
     *
     * @author John-Michael Reed
     * @param target - entity to hit
     * @return -1 if target is null, 0 if attack is a success
     */
    public int sendAttack(Entity target_entity) {
        if (target_entity != null) {
            target_entity.receiveAttack(this.getStatsPack().getOffensive_rating_(), this);
            return 0;
        } else {
            return -1;
        }
    }

    /**
     * Uses the item I am facing on myself. If I have a key the door will unlock
     * itself.\
     *
     * @return 0 on success, -1 on fail (no item to use)
     */
    public int useItemInFacingDirectionOnMyself() {
        Item target = getMapRelation().getTopmostItemInFacingDirection();
        if (target != null) {
            target.use(this);
            return 0;
        }
        return -1;
    }

    /**
     * Call this function when an Entity gains experience points.
     *
     * @param amount - number of experience points
     * @return number of level ups - 0 for no level ups, 1 for 1 level up, 2 for
     * 2 levels up, etc.;
     */
    public int gainExperiencePoints(int amount) {
        int num_level_ups = stats_pack_.increaseQuantityOfExperienceBy(amount);
        num_skillpoints_ += num_level_ups;
        for (int i = 0; i < num_level_ups; ++i) {
            if (getOccupation() != null) {
                getOccupation().changeStats(stats_pack_);
            }
        }
        return num_level_ups;
    }

    public int checkLevel() {
        return stats_pack_.getCached_current_level_();
    }

    // map_relationship_ is used in place of a map_referance_
    private MapEntity_Relation map_relationship_;

    /**
     * Use this to call functions contained within the MapEntity relationship
     *
     * @return map_relationship_
     * @author Reed, John
     */
    public MapEntity_Relation getMapRelation() {
        return map_relationship_;
    }

    /**
     * Set MapEntity_Relation
     *
     * @param e - MapEntity_Relation
     */
    public void setMapRelation(MapEntity_Relation e) {
        map_relationship_ = e;
    }

    private Occupation occupation_ = null;

    /**
     * Get the Entities occupation.
     *
     * @return Occupation of Entity
     */
    public Occupation getOccupation() {
        return occupation_;
    }

    /**
     * Sets Entities Occupation.
     *
     * @param occupation
     */
    public void setOccupation(Occupation occupation) {
        occupation_ = occupation;
    }

    /**
     * Sets Entities Occupation to smasher. Resets stats
     */
    public int becomeSmasher() {
        this.unEquipEverything(); // You cannot change classes if you hold weapons of another class
        if (occupation_ != null) {
            occupation_ = new Smasher(this.occupation_);
        } else {
            occupation_ = new Smasher(this);
        }
        return 0;
    }

    /**
     * Set the entity occupation to it's next sub occupation. Does not reset
     * stats, nor unequip items!! If occupation is null then does nothing
     * Returns -1 if failed to switch due to null occupation, else returns 0.
     *
     * @return -1 or 0
     *
     */
    public int swapSubClass() {
        if (occupation_ != null) {
            occupation_ = occupation_.switchToNextSubOccupation();
            return 0;
        }
        return -1;

    }

    /**
     * Sets Entities Occupation to smasher. Resets stats
     */
    public int becomeSummoner() {
        this.unEquipEverything(); // You cannot change classes if you hold weapons of another class
        if (occupation_ != null) {
            occupation_ = new SummonerRookie(this.occupation_);
        } else {
            occupation_ = new SummonerRookie(this);
        }
        return 0;
    }

    /**
     * Sets Entities Occupation to smasher. Resets stats
     */
    public int becomeSneak() {
        this.unEquipEverything(); // You cannot change classes if you hold weapons of another class
        if (occupation_ != null) {
            occupation_ = new Sneak(this.occupation_);
        } else {
            occupation_ = new Sneak(this);
        }
        return 0;
    }

    /**
     *
     * Override for villager/monster
     *
     * @author John-Michael Reed
     * @param damage - damage received
     * @param attacker - who the attack is coming from. Specify null if the
     * attacker is from an unreachable source i.e. the map
     * @return true if I did not die on attack, false if I did die
     */
    public boolean receiveAttack(int damage, Entity attacker) {
        final int receieved_damage_before_modifiers = damage;
        int amount_of_damage_after_modifiers = damage - (getStatsPack().getDefensive_rating_() + getStatsPack().getArmor_rating_()) / 2;
        // The least damage a valid attack can do is 1.
        if (receieved_damage_before_modifiers > 0 && amount_of_damage_after_modifiers <= 0) {
            amount_of_damage_after_modifiers = 1;
        }
        if (amount_of_damage_after_modifiers < 0) {
            amount_of_damage_after_modifiers = 0;
        }
        System.out.println("Amount of damage recieved in Entity.receiveAttack: " + amount_of_damage_after_modifiers);
        // return -1 if your health ran out, 0 if you did not
        getStatsPack().deductCurrentLifeBy(amount_of_damage_after_modifiers);
        if (stats_pack_.getCurrent_life_() <= 0 && attacker != null) {
            System.out.println("reciever died in in Entity.receiveAttack: ");
            int money = this.num_gold_coins_possessed_;
            this.decrementNumGoldCoinsBy(money); // All money goes to my attacker.
            attacker.incrementNumGoldCoinsBy(money);

            // all my experience goes to my attacker.
            attacker.gainExperiencePoints(this.getStatsPack().getQuantity_of_experience_());
        } else {
            System.out.println("reciever survived in in Entity.receiveAttack: ");
        }
        return checkHealthAndCommitSuicideIfDead(); // returns true if alive, false if dead
    }

    public void receiveHeal(int strength) {
        this.stats_pack_.increaseCurrentLifeBy(strength);
    }

    public void receiveMana(int strength) {
        this.stats_pack_.increaseCurrentManaBy(strength);
    }

    /**
     * Return the combined stats of the entity, includes armour stats.
     */
    public EntityStatsPack getStatsPack() {
        return stats_pack_;
    }

    public String toString() {
        String s = "Entity name(" + getStatsPack().getLives_left_() + "): " + name_;

        /*if (!(equipped_item_ == null)) {
         s += "\n equppied item: " + equipped_item_.name_;
         } else {
         s += "\n equppied item: null";
         }*/
        s += "\n Inventory " + "(" + inventory_.size() + ")" + ":";
        for (int i = 0; i < inventory_.size(); ++i) {
            s += " " + inventory_.get(i).name_;
        }

        s += "\n";

        s += " map_relationship_: ";
        if (map_relationship_ == null) {
            s += "null";
        } else {
            s += "Not null";
        }
        try {
            s += "\n associated with map:" + map_relationship_.isAssociatedWithMap();
        } catch (NullPointerException e) {

        }

        return s;
    }
}


text:
// Copyright (c) 2012, Event Store LLP
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Event Store LLP nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
namespace EventStore.ClientAPI.Transport.Http
{
    internal static class HttpStatusCode
    {
        public const int Continue = (int) System.Net.HttpStatusCode.Continue;
        public const int SwitchingProtocols = (int) System.Net.HttpStatusCode.SwitchingProtocols;
        public const int OK = (int) System.Net.HttpStatusCode.OK;
        public const int Created = (int) System.Net.HttpStatusCode.Created;
        public const int Accepted = (int) System.Net.HttpStatusCode.Accepted;
        public const int NonAuthoritativeInformation = (int) System.Net.HttpStatusCode.NonAuthoritativeInformation;
        public const int NoContent = (int) System.Net.HttpStatusCode.NoContent;
        public const int ResetContent = (int) System.Net.HttpStatusCode.ResetContent;
        public const int PartialContent = (int) System.Net.HttpStatusCode.PartialContent;
        public const int Ambiguous = (int) System.Net.HttpStatusCode.Ambiguous;
        public const int MultipleChoices = (int) System.Net.HttpStatusCode.MultipleChoices;
        public const int Moved = (int) System.Net.HttpStatusCode.Moved;
        public const int MovedPermanently = (int) System.Net.HttpStatusCode.MovedPermanently;
        public const int Found = (int) System.Net.HttpStatusCode.Found;
        public const int Redirect = (int) System.Net.HttpStatusCode.Redirect;
        public const int RedirectMethod = (int) System.Net.HttpStatusCode.RedirectMethod;
        public const int SeeOther = (int) System.Net.HttpStatusCode.SeeOther;
        public const int NotModified = (int) System.Net.HttpStatusCode.NotModified;
        public const int UseProxy = (int) System.Net.HttpStatusCode.UseProxy;
        public const int Unused = (int) System.Net.HttpStatusCode.Unused;
        public const int RedirectKeepVerb = (int) System.Net.HttpStatusCode.RedirectKeepVerb;
        public const int TemporaryRedirect = (int) System.Net.HttpStatusCode.TemporaryRedirect;
        public const int BadRequest = (int) System.Net.HttpStatusCode.BadRequest;
        public const int Unauthorized = (int) System.Net.HttpStatusCode.Unauthorized;
        public const int PaymentRequired = (int) System.Net.HttpStatusCode.PaymentRequired;
        public const int Forbidden = (int) System.Net.HttpStatusCode.Forbidden;
        public const int NotFound = (int) System.Net.HttpStatusCode.NotFound;
        public const int MethodNotAllowed = (int) System.Net.HttpStatusCode.MethodNotAllowed;
        public const int NotAcceptable = (int) System.Net.HttpStatusCode.NotAcceptable;
        public const int ProxyAuthenticationRequired = (int) System.Net.HttpStatusCode.ProxyAuthenticationRequired;
        public const int RequestTimeout = (int) System.Net.HttpStatusCode.RequestTimeout;
        public const int Conflict = (int) System.Net.HttpStatusCode.Conflict;
        public const int Gone = (int) System.Net.HttpStatusCode.Gone;
        public const int LengthRequired = (int) System.Net.HttpStatusCode.LengthRequired;
        public const int PreconditionFailed = (int) System.Net.HttpStatusCode.PreconditionFailed;
        public const int RequestEntityTooLarge = (int) System.Net.HttpStatusCode.RequestEntityTooLarge;
        public const int RequestUriTooLong = (int) System.Net.HttpStatusCode.RequestUriTooLong;
        public const int UnsupportedMediaType = (int) System.Net.HttpStatusCode.UnsupportedMediaType;
        public const int RequestedRangeNotSatisfiable = (int) System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
        public const int ExpectationFailed = (int) System.Net.HttpStatusCode.ExpectationFailed;
        public const int InternalServerError = (int) System.Net.HttpStatusCode.InternalServerError;
        public const int NotImplemented = (int) System.Net.HttpStatusCode.NotImplemented;
        public const int BadGateway = (int) System.Net.HttpStatusCode.BadGateway;
        public const int ServiceUnavailable = (int) System.Net.HttpStatusCode.ServiceUnavailable;
        public const int GatewayTimeout = (int) System.Net.HttpStatusCode.GatewayTimeout;
        public const int HttpVersionNotSupported = (int) System.Net.HttpStatusCode.HttpVersionNotSupported;
    }
}

redpajama_set_name: RedPajamaGithub


text:
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include "../logunit.h"
#include "../util/compare.h"
#include "xlevel.h"
#include "../util/controlfilter.h"
#include "../util/iso8601filter.h"
#include "../util/threadfilter.h"
#include "../util/transformer.h"
#include <iostream>
#include <log4cxx/file.h>
#include <log4cxx/fileappender.h>
#include <apr_pools.h>
#include <apr_file_io.h>
#include "../testchar.h"

using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::xml;

#define TEST1_1A_PAT \
        "(DEBUG|INFO |WARN |ERROR|FATAL) \\w*\\.\\w* - Message [0-9]"

#define TEST1_1B_PAT "(DEBUG|INFO |WARN |ERROR|FATAL) root - Message [0-9]"

#define TEST1_2_PAT "^[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} [0-9]\\{2\\}:[0-9]\\{2\\}:[0-9]\\{2\\},[0-9]\\{3\\} " \
        "\\[0x[0-9A-F]*]\\ (DEBUG|INFO|WARN|ERROR|FATAL) .* - Message [0-9]"

LOGUNIT_CLASS(DOMTestCase)
{
        LOGUNIT_TEST_SUITE(DOMTestCase);
                LOGUNIT_TEST(test1);
#if defined(_WIN32)
                LOGUNIT_TEST(test2);
#endif
                LOGUNIT_TEST(test3);
                LOGUNIT_TEST(test4);
        LOGUNIT_TEST_SUITE_END();

        LoggerPtr root;
        LoggerPtr logger;

        static const File TEMP_A1;
        static const File TEMP_A2;
        static const File FILTERED_A1;
        static const File FILTERED_A2;
        static const File TEMP_A1_2;
        static const File TEMP_A2_2;
        static const File FILTERED_A1_2;
        static const File FILTERED_A2_2;

public:
        void setUp()
        {
                root = Logger::getRootLogger();
                logger = Logger::getLogger(LOG4CXX_TEST_STR("org.apache.log4j.xml.DOMTestCase"));
        }

        void tearDown()
        {
                root->getLoggerRepository()->resetConfiguration();
        }

        void test1() {
                DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase1.xml"));
                common();

                ControlFilter cf1;
                cf1 << TEST1_1A_PAT << TEST1_1B_PAT;

                ControlFilter cf2;
                cf2 << TEST1_2_PAT;

                ThreadFilter threadFilter;
                ISO8601Filter iso8601Filter;

                std::vector<Filter *> filters1;
                filters1.push_back(&cf1);

                std::vector<Filter *> filters2;
                filters2.push_back(&cf2);
                filters2.push_back(&threadFilter);
                filters2.push_back(&iso8601Filter);

                try
                {
                        Transformer::transform(TEMP_A1, FILTERED_A1, filters1);
                        Transformer::transform(TEMP_A2, FILTERED_A2, filters2);
                }
                catch(UnexpectedFormatException& e)
                {
                    std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
                        throw;
                }

                const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.1"));
                const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.1"));
                //   TODO: A1 doesn't contain duplicate entries
                //
                //                LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
                LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
        }

        //
        //   Same test but backslashes instead of forward
        //
        void test2() {
                DOMConfigurator::configure(LOG4CXX_TEST_STR("input\\xml\\DOMTestCase2.xml"));
                common();

                ThreadFilter threadFilter;
                ISO8601Filter iso8601Filter;

                std::vector<Filter *> filters1;

                std::vector<Filter *> filters2;
                filters2.push_back(&threadFilter);
                filters2.push_back(&iso8601Filter);

                try
                {
                        Transformer::transform(TEMP_A1_2, FILTERED_A1_2, filters1);
                        Transformer::transform(TEMP_A2_2, FILTERED_A2_2, filters2);
                }
                catch(UnexpectedFormatException& e)
                {
                    std::cout << "UnexpectedFormatException :" << e.what() << std::endl;
                        throw;
                }

                const File witness1(LOG4CXX_TEST_STR("witness/dom.A1.2"));
                const File witness2(LOG4CXX_TEST_STR("witness/dom.A2.2"));
                //   TODO: A1 doesn't contain duplicate entries
                //
                //                LOGUNIT_ASSERT(Compare::compare(FILTERED_A1, witness1));
                LOGUNIT_ASSERT(Compare::compare(FILTERED_A2, witness2));
        }

        void common()
        {
                int i = 0;

                LOG4CXX_DEBUG(logger, "Message " << i);
                LOG4CXX_DEBUG(root, "Message " << i);

                i++;
                LOG4CXX_INFO(logger, "Message " << i);
                LOG4CXX_INFO(root, "Message " << i);

                i++;
                LOG4CXX_WARN(logger, "Message " << i);
                LOG4CXX_WARN(root, "Message " << i);

                i++;
                LOG4CXX_ERROR(logger, "Message " << i);
                LOG4CXX_ERROR(root, "Message " << i);

                i++;
                LOG4CXX_FATAL(logger, "Message " << i);
                LOG4CXX_FATAL(root, "Message " << i);

        }

        /**
         *   Creates a output file that ends with a superscript 3.
         *   Output file is checked by build.xml after completion.
         */
        void test3() {
                DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml"));
                LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3");
#if LOG4CXX_LOGCHAR_IS_UTF8
                const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xC2, 0xB3, 0 };
#else
                const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xB3, 0 };
#endif
                File file;
                file.setPath(fname);
                Pool p;
                bool exists = file.exists(p);
                LOGUNIT_ASSERT(exists);
        }

        /**
         *   Creates a output file that ends with a ideographic 4.
         *   Output file is checked by build.xml after completion.
         */
        void test4() {
                DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml"));
                LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4");
#if LOG4CXX_LOGCHAR_IS_UTF8
                const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xE3, 0x86, 0x95, 0 };
#else
                const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0x3195, 0 };
#endif
                File file;
                file.setPath(fname);
                Pool p;
                bool exists = file.exists(p);
                LOGUNIT_ASSERT(exists);
        }

};

LOGUNIT_TEST_SUITE_REGISTRATION(DOMTestCase);

const File DOMTestCase::TEMP_A1(LOG4CXX_TEST_STR("output/temp.A1"));
const File DOMTestCase::TEMP_A2(LOG4CXX_TEST_STR("output/temp.A2"));
const File DOMTestCase::FILTERED_A1(LOG4CXX_TEST_STR("output/filtered.A1"));
const File DOMTestCase::FILTERED_A2(LOG4CXX_TEST_STR("output/filtered.A2"));

const File DOMTestCase::TEMP_A1_2(LOG4CXX_TEST_STR("output/temp.A1.2"));
const File DOMTestCase::TEMP_A2_2(LOG4CXX_TEST_STR("output/temp.A2.2"));
const File DOMTestCase::FILTERED_A1_2(LOG4CXX_TEST_STR("output/filtered.A1.2"));
const File DOMTestCase::FILTERED_A2_2(LOG4CXX_TEST_STR("output/filtered.A2.2"));


text:
<html>
<body>
<canvas id=canvas width=600px height=200px>
<script src="bundle.js"></script>
</body>
</html>


text:
var gutil = require('gulp-util'),
  logger = require('./service/logger'),
  through = require('through2'),
  stringHelper = require('./string-helper');

module.exports.bundleName = function(key, type, env, bundleAllEnvironments) {
  var envPrefix = '';
  if (bundleAllEnvironments) {
    envPrefix = env ? env + '.' : 'default.';
  }
  return envPrefix + key + '.' + type;
};

module.exports.bundle = function (key, type, env, bundleAllEnvironments) {
  var bundleName = this.bundleName(key, type, env, bundleAllEnvironments);
  var prefix = "Bundle '" + gutil.colors.green(bundleName) + "' using";
  return through.obj(function (file, enc, cb) {
    logger.log(prefix, gutil.colors.magenta(file.relative));
    this.push(file);
    cb();
  });
};

module.exports.copy = function (base) {
  return through.obj(function (file, enc, cb) {
    var pathReplace = (base === '.') ? file.cwd : base;
    if (!stringHelper.endsWith(pathReplace, '/')) {
      pathReplace += '/';
    }
    logger.log("Copy file", gutil.colors.magenta(file.path.replace(pathReplace, '')));
    this.push(file);
    cb();
  });
};


text:
require 'spec_helper'

describe ImportExportUploader do
  let(:model) { build_stubbed(:import_export_upload) }
  let(:upload) { create(:upload, model: model) }
  let(:import_export_upload) { ImportExportUpload.new }

  subject { described_class.new(model, :import_file) }

  context 'local store' do
    describe '#move_to_store' do
      it 'returns true' do
        expect(subject.move_to_store).to be true
      end
    end
  end

  context "object_store is REMOTE" do
    before do
      stub_uploads_object_storage
    end

    include_context 'with storage', described_class::Store::REMOTE

    it_behaves_like 'builds correct paths',
                    store_dir: %r[import_export_upload/import_file/],
                    upload_path: %r[import_export_upload/import_file/]

    describe '#move_to_store' do
      it 'returns false' do
        expect(subject.move_to_store).to be false
      end
    end

    describe 'with an export file directly uploaded' do
      let(:tempfile) { Tempfile.new(['test', '.gz']) }

      before do
        stub_uploads_object_storage(described_class, direct_upload: true)
        import_export_upload.export_file = tempfile
      end

      it 'cleans up cached file' do
        cache_dir = File.join(import_export_upload.export_file.cache_path(nil), '*')

        import_export_upload.save!

        expect(Dir[cache_dir]).to be_empty
      end
    end
  end
end


text:
- **Malware Incident**
Maintenance and stability enhancements.
- **Malware**
Maintenance and stability enhancements.


text:
@interface GoodActivityTableViewCell()

@property (weak, nonatomic) IBOutlet UIImageView *headerImageView;
@property (weak, nonatomic) IBOutlet UILabel *activityTitleLable;
@property (weak, nonatomic) IBOutlet UILabel *activityDistanceLable;
@property (weak, nonatomic) IBOutlet UILabel *activityPriceLable;

@property (weak, nonatomic) IBOutlet UIButton *loveCountButton;
@property (weak, nonatomic) IBOutlet UILabel *ageLable;
@property (weak, nonatomic) IBOutlet UIImageView *ageBgImageView;

@end

@implementation GoodActivityTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.frame = CGRectMake(0, 0, kWidth, 90);
    self.activityTitleLable.numberOfLines = 0;
}

- (void)setGoodModel:(GoodActivityModel *)goodModel{
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",goodModel.image]] placeholderImage:nil];
    self.activityTitleLable.text = [NSString stringWithFormat:@"%@", goodModel.title];
    self.activityPriceLable.text = [NSString stringWithFormat:@"%@", goodModel.price];
    [self.loveCountButton setTitle:[NSString stringWithFormat:@"%@",goodModel.counts] forState:UIControlStateNormal];
    self.ageLable.text =  goodModel.age;
    NSNumber *lat = [[NSUserDefaults standardUserDefaults] valueForKey:@"lat"];
    NSNumber *lng = [[NSUserDefaults standardUserDefaults] valueForKey:@"lng"];

    CLLocation *orig=[[CLLocation alloc] initWithLatitude:[lat floatValue]  longitude:[lng floatValue]];
    CLLocation* dist=[[CLLocation alloc] initWithLatitude:goodModel.lat longitude:goodModel.lng];

    CLLocationDistance kilometers=[dist distanceFromLocation:orig]/1000;
    self.activityDistanceLable.text = [NSString stringWithFormat:@"%.fKm", kilometers];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


text:
import React from 'react';
import NavigationMoreVertIcon from 'material-ui/svg-icons/navigation/more-vert';
import IconButton from 'material-ui/IconButton';
import IconMenu from 'material-ui/IconMenu';
import MenuItem from 'material-ui/MenuItem';
import { Link } from 'react-router';

const Logged = (props) => (
  <IconMenu
    {...props}
    iconButtonElement={
      <IconButton><NavigationMoreVertIcon /></IconButton>
    }
    targetOrigin={{ horizontal: 'right', vertical: 'top' }}
    anchorOrigin={{ horizontal: 'right', vertical: 'top' }}
  >
    <MenuItem primaryText="Login" containerElement={<Link to="/login" />} />
    <MenuItem primaryText="Sign up" containerElement={<Link to="/signup" />} />
  </IconMenu>
);

Logged.muiName = 'IconMenu';

export default Logged;


text:
<readable><title>2856700531_312528eea4</title><content>
A man in a black jacket with a black beard stares pensively .
A man in a jacket looks out .
A man sits and rubs his chin .
A man with a Mohawk and beard , with his hand on his chin looking off into the distance .
an asian man thinks to himself .
</content></readable>


text:
if ($ENV:PROCESSOR_ARCHITEW6432 -eq 'AMD64')
{
   try
   {
      &"$ENV:WINDIR\SysNative\WindowsPowershell\v1.0\PowerShell.exe" -File $PSCOMMANDPATH
   }
   catch
   {
      Throw ('Failed to start {0}' -f $PSCOMMANDPATH)
   }

   exit
}
#endregion ARM64Handling

#region Remediation
$RegistryPathTwo = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
$RegistryPathOne = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'

if ((Test-Path -LiteralPath $RegistryPathOne) -ne $true)
{
   $null = (New-Item -Path $RegistryPathOne -Force -Confirm:$false -ErrorAction SilentlyContinue)
}

if ((Test-Path -LiteralPath $RegistryPathTwo) -ne $true)
{
   $null = (New-Item -Path $RegistryPathTwo -Force -Confirm:$false -ErrorAction SilentlyContinue)
}

$null = (New-ItemProperty -LiteralPath $RegistryPathOne -Name 'DisableCAD' -Value 0 -PropertyType DWord -Force -Confirm:$false -ErrorAction SilentlyContinue)

$null = (New-ItemProperty -LiteralPath $RegistryPathTwo -Name 'DisableCAD' -Value 0 -PropertyType DWord -Force -Confirm:$false -ErrorAction SilentlyContinue)
#endregion Remediation