def getGoalsString(): value = "" latSpan = 2* metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2* metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapGoals if goalAmount<5: goalSpanID = random.sample([0,2,6,8],goalAmount) if goalAmount>4: goalSpanID = [0,2,6,8] + random.sample([1,3,5,7],goalAmount-4) for x in range(goalAmount): # lat = areaBottom + (0.1 +0.8*random())*latSpan # lng = areaLeft + (0.1 +0.8*random())*lngSpan lat = areaBottom + (0.05 +0.3*random.random()+0.3*(goalSpanID[x]/3))*latSpan lng = areaLeft + (0.05 +0.3*random.random()+0.3*(goalSpanID[x]%3))*lngSpan goal = Item(int(lat*float(10**6)), int( lng*float(10**6)), 0, "I'm a goal state!") goal.crownClaimRadius = crownClaimRadius value = value + goal.toString()+ "," #Add the item to the list of items mapGoals[goal.id] = goal return value[0:-2]
def getItemsString(): value = "" latSpan = 2* metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2* metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapItems global itemSpanID for x in range(int(itemAmount/9)): itemSpanID = itemSpanID + spanID itemSpanID = itemSpanID + random.sample(spanID,itemAmount%9) for x in range(itemAmount): # lat = areaBottom + (0.1 +0.8*random())*latSpan # lng = areaLeft + (0.1 +0.8*random())*lngSpan lat = areaBottom + (0.05 +0.3*random.random()+0.3*(itemSpanID[x]/3))*latSpan lng = areaLeft + (0.05 +0.3*random.random()+0.3*(itemSpanID[x]%3))*lngSpan item = Item(int(lat*float(10**6)), int( lng*float(10**6)), 1+int(random.random()*6), "I'm an item!") #item = Item(int(lat*float(10**6)), int( lng*float(10**6)),5, "I'm an item!") value = value + item.toString()+ "," #Add the item to the list of items mapItems[item.id] = item return value[0:-2]
def getGoalsString(): value = "" latSpan = 2 * metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2 * metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapGoals if goalAmount < 5: goalSpanID = random.sample([0, 2, 6, 8], goalAmount) if goalAmount > 4: goalSpanID = [0, 2, 6, 8] + random.sample([1, 3, 5, 7], goalAmount - 4) for x in range(goalAmount): # lat = areaBottom + (0.1 +0.8*random())*latSpan # lng = areaLeft + (0.1 +0.8*random())*lngSpan lat = areaBottom + (0.05 + 0.3 * random.random() + 0.3 * (goalSpanID[x] / 3)) * latSpan lng = areaLeft + (0.05 + 0.3 * random.random() + 0.3 * (goalSpanID[x] % 3)) * lngSpan goal = Item(int(lat * float(10**6)), int(lng * float(10**6)), 0, "I'm a goal state!") goal.crownClaimRadius = crownClaimRadius value = value + goal.toString() + "," #Add the item to the list of items mapGoals[goal.id] = goal return value[0:-2]
def getItemsString(): value = "" latSpan = 2 * metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2 * metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapItems global itemSpanID for x in range(int(itemAmount / 9)): itemSpanID = itemSpanID + spanID itemSpanID = itemSpanID + random.sample(spanID, itemAmount % 9) for x in range(itemAmount): # lat = areaBottom + (0.1 +0.8*random())*latSpan # lng = areaLeft + (0.1 +0.8*random())*lngSpan lat = areaBottom + (0.05 + 0.3 * random.random() + 0.3 * (itemSpanID[x] / 3)) * latSpan lng = areaLeft + (0.05 + 0.3 * random.random() + 0.3 * (itemSpanID[x] % 3)) * lngSpan item = Item(int(lat * float(10**6)), int(lng * float(10**6)), 1 + int(random.random() * 6), "I'm an item!") #item = Item(int(lat*float(10**6)), int( lng*float(10**6)),5, "I'm an item!") value = value + item.toString() + "," #Add the item to the list of items mapItems[item.id] = item return value[0:-2]
def calculateAreaBounds(): latDelta = metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngDelta = metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global areaLeft, areaRight, areaTop, areaBottom areaLeft = centerLng - lngDelta areaRight = centerLng + lngDelta areaTop = centerLat + latDelta areaBottom = centerLat - latDelta
def teleportItem(itemId): latSpan = 2* metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2* metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapItems lat = areaBottom + (0.05 +0.9*random.random())*latSpan lng = areaLeft + (0.05 +0.9*random.random())*lngSpan mapItems[itemId].lat = int(lat*float(10**6)) mapItems[itemId].lng = int(lng*float(10**6)) return mapItems[itemId]
def teleportItem(itemId): latSpan = 2 * metricDistanceToLatitudeDistance(centerLat, halfAreaSize) lngSpan = 2 * metricDistanceToLongditudeDistance(centerLat, halfAreaSize) global mapItems lat = areaBottom + (0.05 + 0.9 * random.random()) * latSpan lng = areaLeft + (0.05 + 0.9 * random.random()) * lngSpan mapItems[itemId].lat = int(lat * float(10**6)) mapItems[itemId].lng = int(lng * float(10**6)) return mapItems[itemId]