Skip to content

Instantly share code, notes, and snippets.

@danalexilewis
Created September 19, 2014 04:38
Show Gist options
  • Save danalexilewis/b8c7b0cbee4697a33b44 to your computer and use it in GitHub Desktop.
Save danalexilewis/b8c7b0cbee4697a33b44 to your computer and use it in GitHub Desktop.
GIS-Chaser, Code i am proud of
namespace GIS_Chaser.Models
{
public class GemModel
{
private IGemStorage _gemStorage { get; set; }
public GemModel(IGemStorage gemStorage)
{
_gemStorage = gemStorage;
}
public List<Gems> GetGemsForUser(string id)
{
return _gemStorage.GetAll();
}
public void AutoAddGem()
{
_gemStorage.Persist(CreateRandomGem());
}
public Gems CreateRandomGem()
{
return AssembleGem(RandomGemType(), RandomPointValue(), RandomCellId());
}
public Gems AssembleGem(int type, int points, int cellId)
{
Gems gem = new Gems { GemType = type, PointsValue = points*type};
gem.Positions.CellId = cellId;
return gem;
}
private int RandomCellId()
{
Random random = new Random();
return random.Next(1, 600);
}
private int RandomGemType()
{
Random random = new Random();
return random.Next(1, 4);
}
private int RandomPointValue()
{
Random random = new Random();
return random.Next(10, 25);
}
// max and mins for lats and longs
// RandomLatitude(286292, 314453), RandomLongitude(742851, 824000)
private double RandomLatitude(int min, int max )
{
Random random = new Random();
return (double)random.Next(min, max) / 100000 + 41;
}
private double RandomLongitude(int min, int max)
{
Random random = new Random();
return (double)random.Next(min, max) / 100000 + 174;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment