<commit_before>import {dice} from 'dice'
import {Actor} from '../universe/actor/actor.js'
import {TerrainObject} from '../universe/items/terrainObject.js'


var Chance = require('chance')

export class Generator {
  constructor(props) {
  }

	// =============================
		
	generateBush(props) {
		return this.generateTerrainObject({name: "Bush",	assetId: "desert_bush_01", hp: 10})
	}

	generateRock(props) {
		return this.generateTerrainObject({name: "Rock",	assetId: "desert_rock", hp: 1000})
	}


	generateCreature(props) {
		let name = chance.name()
		return this.generateActor({name: name,	assetId: "droid"})
	}


	// =============================

	generateLocation(props) {
		
		let id
		if (props && props.id) {
			id = props.id
		} else {
			id = "map-"
			id += Date.now()
			id += "-"
			id += dice.rollD20(10).value
		}
		
		let height = 16
		let width = 24
		let name = chance.city()

		let allObjects = []

		let terrain = []
		let creatures = []
		let items = []
				
    for (var y = 0; y < height; y++) {
      for (var x = 0; x < width; x++)  {
				if (x>2) {
					if (dice.rollBool(20)) {   // terrain?
						let obj = {}
						if (dice.rollBool(20)) {   // rock?
							obj = this.generateRock()
						} else {
							obj = this.generateBush()							
						}
						terrain.push({object: obj, x: x, y: y})
						allObjects.push({object: obj, x: x, y: y})
					// actor?
					} else if (dice.rollBool(1)) { // creature?
						let obj = this.generateCreature()
						creatures.push({object: obj, x: x, y: y})
						allObjects.push({object: obj, x: x, y: y})
					}
				} 
      }
    }		
		
		let loc = {
			id: id,
			name: name,
			height: height,
			width: width,
			
			terrain: terrain,
			creatures: creatures,
			items: items,
			
			allObjects: allObjects
		}
		
		return loc
	}


	generateTerrainObject(props) {

		let id
		if (props && props.id) {
			id = props.id
		}	 else {
			id = "terrain-"
			id += Date.now()
			id += "-"
			id += dice.rollD20(10).value
		}

		let hp
		if (props && props.hp) {
			hp = props.hp
		}	else {
			hp = dice.rollD10(5).value
		}
		let object = new TerrainObject({id: props.id, name: props.name, hpMax: props.hp, assetId: props.assetId})<commit_msg>id generation fixed<commit_after>import {dice} from 'dice'
import {Actor} from '../universe/actor/actor.js'
import {TerrainObject} from '../universe/items/terrainObject.js'


var Chance = require('chance')

export class Generator {
  constructor(props) {
  }

	// =============================
		
	generateBush(props) {
		return this.generateTerrainObject({name: "Bush",	assetId: "desert_bush_01", hp: 10})
	}

	generateRock(props) {
		return this.generateTerrainObject({name: "Rock",	assetId: "desert_rock", hp: 1000})
	}


	generateCreature(props) {
		let name = chance.name()
		return this.generateActor({name: name,	assetId: "droid"})
	}


	// =============================

	generateLocation(props) {
		
		let id
		if (props && props.id) {
			id = props.id
		} else {
			id = "map-"
			id += Date.now()
			id += "-"
			id += dice.rollD20(10).value
		}
		
		let height = 16
		let width = 24
		let name = chance.city()

		let allObjects = []

		let terrain = []
		let creatures = []
		let items = []
				
    for (var y = 0; y < height; y++) {
      for (var x = 0; x < width; x++)  {
				if (x>2) {
					if (dice.rollBool(20)) {   // terrain?
						let obj = {}
						if (dice.rollBool(20)) {   // rock?
							obj = this.generateRock()
						} else {
							obj = this.generateBush()							
						}
						terrain.push({object: obj, x: x, y: y})
						allObjects.push({object: obj, x: x, y: y})
					// actor?
					} else if (dice.rollBool(1)) { // creature?
						let obj = this.generateCreature()
						creatures.push({object: obj, x: x, y: y})
						allObjects.push({object: obj, x: x, y: y})
					}
				} 
      }
    }		
		
		let loc = {
			id: id,
			name: name,
			height: height,
			width: width,
			
			terrain: terrain,
			creatures: creatures,
			items: items,
			
			allObjects: allObjects
		}
		
		return loc
	}


	generateTerrainObject(props) {

		let id
		if (props && props.id) {
			id = props.id
		}	 else {
			id = "terrain-"
			id += Date.now()
			id += "-"
			id += dice.rollD20(10).value
		}

		let hp
		if (props && props.hp) {
			hp = props.hp
		}	else {
			hp = dice.rollD10(5).value
		}
		
		let object = new TerrainObject({id: id, name: props.name, hpMax: props.hp, assetId: props.assetId})
{'fraction_non_alphanumeric': 0.1823304034257381, 'fraction_numerical': 0.013973405454135676, 'mean_word_length': 2.4059861857252494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7354691', 'n_tokens_mistral': 2062, 'n_tokens_neox': 1606, 'n_words': 391}