Пример #1
0
void ComputeAdventure() {
	
	uint16_t rand = 0;
	if(entriesSize != 1) {
		rand = Random(entriesSize);
	}	
	DEBUG_VERBOSE_LOG("Random: %d", rand);
	Card* card;
	do {
		 card = &entries[rand];
		 rand = (rand + 1) % NB_TYPE_CARDS;
	} while(card->empty);
	
	DEBUG_VERBOSE_LOG("Random Modified: %d", rand);	
	
	card->windowFunction();	
	card->taken += 1;	
	
	DEBUG_LOG("Card Taken: %d/%d", card->taken, card->total);	
	DEBUG_VERBOSE_LOG("Card Type Left: %d", entriesSize);
	
	if(card->taken == card->total) {
		entriesSize--;
		card->empty = true;
		if(entriesSize == 0) {
			ResetCurrentTaken();
		}
	}	
}
Пример #2
0
void UpdateBatteryText(BatteryChargeState chargeState, char *buffer, int count)
{
	DEBUG_VERBOSE_LOG("Updating battery text");
	if (chargeState.is_charging) {
		snprintf(buffer, count, "Chg");
	} else if(chargeState.charge_percent == 100) {
		snprintf(buffer, count, "Full");
	} else {
		IntToPercent(buffer, count, chargeState.charge_percent);
	}	
	
	DEBUG_VERBOSE_LOG("Drawing new battery info");
}
Пример #3
0
// Right justified
void IntToString(char *buffer, size_t bufferSize, int value)
{
	int i = bufferSize - 1;
	int digit;
	int temp = value;

	DEBUG_VERBOSE_LOG("IntToString(%d)", value);
	
	do
	{
		digit = temp % 10;
		buffer[i] = '0' + digit;
		temp /= 10;
		--i;
	} while(temp);

	while(i >= 0)
	{
#if PAD_WITH_SPACES
		buffer[i] = ' ';
#else
		buffer[i] = '0';
#endif
		--i;
	}
}
Пример #4
0
void SetCardSave(CardSave * saves) {
	for(uint8_t i = 0; i < NB_TYPE_CARDS; i++) {
		DEBUG_VERBOSE_LOG("Card Taken: %d\nisEmpty: %d", saves[i].taken, saves[i].empty);
		(&entries[i])->taken = saves[i].taken;
		(&entries[i])->empty = saves[i].empty;
	}
}
Пример #5
0
void GetCardSaves(CardSave* saves) {
	memset(saves, 0, NB_TYPE_CARDS * sizeof(CardSave));
	for(uint8_t i = 0; i < NB_TYPE_CARDS; i++) {
		saves[i].taken = entries[i].taken;
		saves[i].empty = entries[i].empty;
		DEBUG_VERBOSE_LOG("Card Taken: %d\nisEmpty: %d", saves[i].taken, saves[i].empty);
	}
}
Пример #6
0
bool SavePersistedData(void)
{
	CharacterData *characterData;

	if(!IsPersistedDataCurrent())
	{
		WARNING_LOG("Persisted data does not match current version, clearing.");
		ClearPersistedData();
	}
	
	if(sizeof(CharacterData) > PERSIST_DATA_MAX_LENGTH )
	{
		ERROR_LOG("CharacterData is too big to save (%d).", sizeof(CharacterData));
		return false;
	}

	if(GetSizeOfItemsOwned() > PERSIST_DATA_MAX_LENGTH )
	{
		ERROR_LOG("Item data is too big to save (%d).", GetSizeOfItemsOwned());
		return false;
	}

	ProfileLogStart("SavePersistedData");
	INFO_LOG("Saving persisted data.");
	DEBUG_VERBOSE_LOG("Saving meta data");
	persist_write_bool(PERSISTED_IS_DATA_SAVED, true);
	persist_write_int(PERSISTED_CURRENT_DATA_VERSION, CURRENT_DATA_VERSION);
	persist_write_int(PERSISTED_MAX_KEY_USED, MAX_PERSISTED_KEY);
	
	DEBUG_VERBOSE_LOG("Saving character");
	characterData = GetCharacter();
	persist_write_data(PERSISTED_CHARACTER_DATA, characterData, sizeof(CharacterData));
	
	DEBUG_VERBOSE_LOG("Saving floor");
	persist_write_int(PERSISTED_CURRENT_FLOOR, GetCurrentFloor());
	
	DEBUG_VERBOSE_LOG("Saving item data");
	persist_write_data(PERSISTED_ITEM_DATA, GetItemsOwned(), GetSizeOfItemsOwned());
	
	DEBUG_VERBOSE_LOG("Saving stat points");
	persist_write_int(PERSISTED_STAT_POINTS_PURCHASED, GetStatPointsPurchased());

	DEBUG_VERBOSE_LOG("Saving option data");
	persist_write_bool(PERSISTED_VIBRATION, GetVibration());
	persist_write_bool(PERSISTED_FAST_MODE, GetFastMode());
	persist_write_bool(PERSISTED_WORKER_APP, GetWorkerApp());
	persist_write_bool(PERSISTED_WORKER_CAN_LAUNCH, GetWorkerCanLaunch());
	persist_write_bool(PERSISTED_USE_OLD_ASSETS, GetUseOldAssets());

	DEBUG_VERBOSE_LOG("Saving combat data");
	persist_write_bool(PERSISTED_IN_COMBAT, ClosingWhileInBattle());
	persist_write_int(PERSISTED_MONSTER_TYPE, GetMostRecentMonster());
	persist_write_int(PERSISTED_MONSTER_HEALTH, GetCurrentMonsterHealth());
	INFO_LOG("Done saving persisted data.");
	ProfileLogStop("SavePersistedData");
	
	return true;
}
Пример #7
0
// Returns an integer in the range [0,max)
uint16_t Random(uint16_t max)
{
	int result = Random_inline(max);
	DEBUG_VERBOSE_LOG("Random(%d)=%d", max, result);
	return result;
}
Пример #8
0
void BatteryHandler(BatteryChargeState charge)
{
	DEBUG_VERBOSE_LOG("BatteryHandler called");
	if(mainMenuVisible)
		ShowPauseRow(charge);
}