Added Enchantment-Slot-Level generating
This commit is contained in:
parent
7735a1104f
commit
af566d5a79
@ -172,3 +172,13 @@ float cFastRandom::NextFloat(float a_Range, int a_Salt)
|
||||
|
||||
|
||||
|
||||
|
||||
int cFastRandom::GenerateRandomInteger(int a_Begin, int a_End)
|
||||
{
|
||||
cFastRandom Random;
|
||||
return Random.NextInt(a_End - a_Begin + 1) + a_Begin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
|
||||
/// Returns a random float in the range [0 .. a_Range]; a_Range must be less than 1M; a_Salt is additional source of randomness
|
||||
float NextFloat(float a_Range, int a_Salt);
|
||||
|
||||
/// Returns a random int in the range [a_Begin .. a_End]
|
||||
int GenerateRandomInteger(int a_Begin, int a_End);
|
||||
|
||||
protected:
|
||||
int m_Seed;
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "Window.h"
|
||||
#include "../CraftingRecipes.h"
|
||||
#include "../Root.h"
|
||||
#include "../FastRandom.h"
|
||||
#include "../BlockArea.h"
|
||||
|
||||
|
||||
|
||||
@ -615,23 +617,31 @@ void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
|
||||
if (a_Player.GetDraggingItem().IsEmpty())
|
||||
{
|
||||
LOGWARN("EMPTY");
|
||||
this->m_ParentWindow.SetProperty(0, 0);
|
||||
this->m_ParentWindow.SetProperty(1, 0);
|
||||
this->m_ParentWindow.SetProperty(2, 0);
|
||||
m_ParentWindow.SetProperty(0, 0);
|
||||
m_ParentWindow.SetProperty(1, 0);
|
||||
m_ParentWindow.SetProperty(2, 0);
|
||||
}
|
||||
else if (a_Player.GetDraggingItem().IsEnchantable)
|
||||
{
|
||||
int bookshelves = 15; // TODO: Check Bookshelves
|
||||
|
||||
cFastRandom Random;
|
||||
int base = (Random.GenerateRandomInteger(1, 8) + floor(bookshelves / 2) + Random.GenerateRandomInteger(0, bookshelves));
|
||||
int topSlot = std::max(base / 3, 1);
|
||||
int middleSlot = (base * 2) / 3 + 1;
|
||||
int bottomSlot = std::max(base, bookshelves * 2);
|
||||
|
||||
LOGWARN("Enchantable");
|
||||
this->m_ParentWindow.SetProperty(0, 30);
|
||||
this->m_ParentWindow.SetProperty(1, 20);
|
||||
this->m_ParentWindow.SetProperty(2, 10);
|
||||
m_ParentWindow.SetProperty(0, topSlot);
|
||||
m_ParentWindow.SetProperty(1, middleSlot);
|
||||
m_ParentWindow.SetProperty(2, bottomSlot);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGWARN("Not Enchantable");
|
||||
this->m_ParentWindow.SetProperty(0, 0);
|
||||
this->m_ParentWindow.SetProperty(1, 0);
|
||||
this->m_ParentWindow.SetProperty(2, 0);
|
||||
m_ParentWindow.SetProperty(0, 0);
|
||||
m_ParentWindow.SetProperty(1, 0);
|
||||
m_ParentWindow.SetProperty(2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user