<commit_before>#include "pch.h"
#include "Computer.h"
#include "GameManager.h"
#include "ComponentManager.h"
#include "InputManager.h"
#include "SpriteComponent.h"
#include "GaugeBarContainer.h"
#include "EffectManager.h"
#include "SoundManager.h"
#include "StageManager.h"
#include "Player.h"
#include "DataManager.h"
#include "EquipmentAbstract.h"
#include "UpMoveEffect.h"

bool Computer::init()
{
	if(!NPC::init())
	{
		return false;
	}
	m_Type = OT_COMPUTER;
	m_Info.m_Size = cocos2d::Size(COMPUTER_WIDTH, COMPUTER_HEIGHT);
	bodyInit(m_Info.m_Size);
	initFSMAndTransition();
	m_Bar = GaugeBarContainer::create();
	m_Bar->initBarContainer(this, ST_BAR_CONTAINER, ST_BAR, cocos2d::Point(0, LOADING_BAR_HEIGHT));
	addComponent(m_Bar);
	setLoadingTime(3.f);
	return true;
}

void Computer::update(float dTime)
{
	Creature::update(dTime);
}

void Computer::exit()
{
	//removeFromParent();
}

void Computer::enter()
{

}

void Computer::dead()
{
	setEnabled(false);
	m_Body->release();
}

void Computer::available(Creature* target, double dTime, int idx)
{

}

void Computer::loading(Creature* target, double dTime, int idx)
{
	if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_HOLD)
	{
		float curPercent = m_Bar->getBarPercent();
		if(curPercent < 100)
		{
			m_Bar->setBarPercent(curPercent + dTime * m_LoadingSpeed);
		}
		else
		{
			m_IsComplete = true;
		}
	}
}

void Computer::complete(Creature* target, double dTime, int idx)
{

}

void Computer::idleTransition(Creature* target, double dTime, int idx)
{
	if(m_OnContact)
	{
		availableEnter(dTime, idx);
		setState(idx, Computer::STAT_AVAILABLE);
	}
}

void Computer::availableTransition(Creature* target, double dTime, int idx)
{
	if(!m_OnContact)
	{
		availableExit(dTime, idx);
		setState(idx, Computer::STAT_IDLE);
	}
	else if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_PRESS)
	{
		GET_SOUND_MANAGER()->createSound(SoundManager::CHARGEGAGE, false);
		availableExit(dTime, idx);
		loadingEnter(dTime, idx);
		setState(idx, Computer::STAT_LOADING);
	}
}

void Computer::loadingTransition(Creature* target, double dTime, int idx)
{
	if(!m_OnContact)
	{
		loadingExit(dTime, idx);
		setState(idx, Computer::STAT_IDLE);
	}
	else if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_RELEASE)
	{
		loadingExit(dTime, idx);
		availableEnter(dTime, idx);
		setState(idx, Computer::STAT_AVAILABLE);
	}
	else if(m_IsComplete)
	{
		loadingExit(dTime, idx);
		GET_SOUND_MANAGER()->createSound(SoundManager::GETMONEY, false);
		completeEnter(dTime, idx);
		setState(idx, Computer::STAT_COMPLETE);
	}
}

void Computer::completeTransition(Creature* target, double dTime, int idx)
{
}

void Computer::availableEnter(double dTime, int idx)
{
}

void Computer::availableExit(double dTime, int idx)
{
}

void Computer::loadingEnter(double dTime, int idx)
{
	m_Bar->enter();
}

void Computer::loadingExit(double dTime, int idx)
{
	m_Bar->exit();
	m_Bar->setBarPercent(0.f);
}

void Computer::completeEnter(double dTime, int idx)
{
	UpMoveEffect* effect = static_cast<UpMoveEffect*>
		(GET_EFFECT_MANAGER()->createEffect(ET_UP_MOVE, getPosition() + cocos2d::Point(0, m_Info.m_Size.height / 2)));

	auto player = GET_STAGE_MANAGER()->getPlayer();
	auto info = player->getInfo();
	int randomValue = rand() % 100;
	if(randomValue < 10 && GET_DATA_MANAGER()->getLockSkillNum() > 0)
	//10% Ȯ     ų ϳ ȹ.
	{
		SkillType category;
		int type;
		
		do
		{
			category = static_cast<SkillType>(rand() %SKILL_NUM);
			type = rand() % 2/*GET_DATA_MANAGER()->getSkillNum(category)*/;
		} while (!GET_DATA_MANAGER()->getSkillInfo(category, type)->m_IsLock);

		GET_DATA_MANAGER()->setSkillLock(category, type, false);
		effect->setAnimation(AT_EFFECT_SKILL);
	}
	else if (randomValue < 30 && GET_DATA_MANAGER()->getLockItemNum()>0)
	//20% Ȯ      ϳ ȹ.
	{
		EquipmentType category;
		int type;

		do
		{
			category = static_cast<EquipmentType>(rand() % SKILL_NUM);
			type = rand() % 2/*GET_DATA_MANAGER()->getItemNum(category)*/;
		} while (!GET_DATA_MANAGER()->getEquipmentInfo(category, type)->m_IsLock);

		GET_DATA_MANAGER()->setItemLock(category, type, false);
		effect->setAnimation(AT_EFFECT_BLUEPRINT);
	}
	else
	//   Ʈ ȹ.
	{
		info.m_BitCoin += 100;
		player->setInfo(info);
		effect->setAnimation(AT_EFFECT_COIN);
	}

	effect->enter();

	// ȹϸ ٷιٷ 
	GET_DATA_MANAGER()->saveGameData();<commit_msg>위에서 4개까지 아이템들만 언락되던 버그 수정<commit_after>#include "pch.h"
#include "Computer.h"
#include "GameManager.h"
#include "ComponentManager.h"
#include "InputManager.h"
#include "SpriteComponent.h"
#include "GaugeBarContainer.h"
#include "EffectManager.h"
#include "SoundManager.h"
#include "StageManager.h"
#include "Player.h"
#include "DataManager.h"
#include "EquipmentAbstract.h"
#include "UpMoveEffect.h"

bool Computer::init()
{
	if(!NPC::init())
	{
		return false;
	}
	m_Type = OT_COMPUTER;
	m_Info.m_Size = cocos2d::Size(COMPUTER_WIDTH, COMPUTER_HEIGHT);
	bodyInit(m_Info.m_Size);
	initFSMAndTransition();
	m_Bar = GaugeBarContainer::create();
	m_Bar->initBarContainer(this, ST_BAR_CONTAINER, ST_BAR, cocos2d::Point(0, LOADING_BAR_HEIGHT));
	addComponent(m_Bar);
	setLoadingTime(3.f);
	return true;
}

void Computer::update(float dTime)
{
	Creature::update(dTime);
}

void Computer::exit()
{
	//removeFromParent();
}

void Computer::enter()
{

}

void Computer::dead()
{
	setEnabled(false);
	m_Body->release();
}

void Computer::available(Creature* target, double dTime, int idx)
{

}

void Computer::loading(Creature* target, double dTime, int idx)
{
	if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_HOLD)
	{
		float curPercent = m_Bar->getBarPercent();
		if(curPercent < 100)
		{
			m_Bar->setBarPercent(curPercent + dTime * m_LoadingSpeed);
		}
		else
		{
			m_IsComplete = true;
		}
	}
}

void Computer::complete(Creature* target, double dTime, int idx)
{

}

void Computer::idleTransition(Creature* target, double dTime, int idx)
{
	if(m_OnContact)
	{
		availableEnter(dTime, idx);
		setState(idx, Computer::STAT_AVAILABLE);
	}
}

void Computer::availableTransition(Creature* target, double dTime, int idx)
{
	if(!m_OnContact)
	{
		availableExit(dTime, idx);
		setState(idx, Computer::STAT_IDLE);
	}
	else if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_PRESS)
	{
		GET_SOUND_MANAGER()->createSound(SoundManager::CHARGEGAGE, false);
		availableExit(dTime, idx);
		loadingEnter(dTime, idx);
		setState(idx, Computer::STAT_LOADING);
	}
}

void Computer::loadingTransition(Creature* target, double dTime, int idx)
{
	if(!m_OnContact)
	{
		loadingExit(dTime, idx);
		setState(idx, Computer::STAT_IDLE);
	}
	else if(GET_INPUT_MANAGER()->getKeyState(KC_INTERACT) == KS_RELEASE)
	{
		loadingExit(dTime, idx);
		availableEnter(dTime, idx);
		setState(idx, Computer::STAT_AVAILABLE);
	}
	else if(m_IsComplete)
	{
		loadingExit(dTime, idx);
		GET_SOUND_MANAGER()->createSound(SoundManager::GETMONEY, false);
		completeEnter(dTime, idx);
		setState(idx, Computer::STAT_COMPLETE);
	}
}

void Computer::completeTransition(Creature* target, double dTime, int idx)
{
}

void Computer::availableEnter(double dTime, int idx)
{
}

void Computer::availableExit(double dTime, int idx)
{
}

void Computer::loadingEnter(double dTime, int idx)
{
	m_Bar->enter();
}

void Computer::loadingExit(double dTime, int idx)
{
	m_Bar->exit();
	m_Bar->setBarPercent(0.f);
}

void Computer::completeEnter(double dTime, int idx)
{
	UpMoveEffect* effect = static_cast<UpMoveEffect*>
		(GET_EFFECT_MANAGER()->createEffect(ET_UP_MOVE, getPosition() + cocos2d::Point(0, m_Info.m_Size.height / 2)));

	auto player = GET_STAGE_MANAGER()->getPlayer();
	auto info = player->getInfo();
	int randomValue = rand() % 100;
	if(randomValue < 10 && GET_DATA_MANAGER()->getLockSkillNum() > 0)
	//10% Ȯ     ų ϳ ȹ.
	{
		SkillType category;
		int type;
		
		do
		{
			category = static_cast<SkillType>(rand() %SKILL_NUM);
			type = rand() % 2/*GET_DATA_MANAGER()->getSkillNum(category)*/;
		} while (!GET_DATA_MANAGER()->getSkillInfo(category, type)->m_IsLock);

		GET_DATA_MANAGER()->setSkillLock(category, type, false);
		effect->setAnimation(AT_EFFECT_SKILL);
	}
	else if (randomValue < 30 && GET_DATA_MANAGER()->getLockItemNum()>0)
	//20% Ȯ      ϳ ȹ.
	{
		EquipmentType category;
		int type;

		do
		{
			category = static_cast<EquipmentType>(rand() % EMT_NUM);
			type = rand() % 2/*GET_DATA_MANAGER()->getItemNum(category)*/;
		} while (!GET_DATA_MANAGER()->getEquipmentInfo(category, type)->m_IsLock);

		GET_DATA_MANAGER()->setItemLock(category, type, false);
		effect->setAnimation(AT_EFFECT_BLUEPRINT);
	}
	else
	//   Ʈ ȹ.
	{
		info.m_BitCoin += 100;
		player->setInfo(info);
		effect->setAnimation(AT_EFFECT_COIN);
	}

	effect->enter();

	// ȹϸ ٷιٷ 
	GET_DATA_MANAGER()->saveGameData();
{'fraction_non_alphanumeric': 0.1529276693455798, 'fraction_numerical': 0.006773823191733639, 'mean_word_length': 5.659785932721713, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 75, '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': '4096944', 'n_tokens_mistral': 3549, 'n_tokens_neox': 3394, 'n_words': 568}