-
-
Save danalexilewis/b8c7b0cbee4697a33b44 to your computer and use it in GitHub Desktop.
GIS-Chaser, Code i am proud of
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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