Skip to content
Snippets Groups Projects

Development to testing

Merged Ghost User requested to merge Development into testing
1 file
+ 18
14
Compare changes
  • Side-by-side
  • Inline
+ 18
14
@@ -30,13 +30,7 @@ export class DrawService {
@@ -30,13 +30,7 @@ export class DrawService {
drawing.faction = gameperson.faction;
drawing.faction = gameperson.faction;
const mapDrawing = await this.mapDrawingRepository.insert(drawing);
const mapDrawing = await this.mapDrawingRepository.insert(drawing);
// create a history entity and insert it
// create a history entity and insert it
const history = await this.mapDrawHistoryRepository.create({
await this.createHistory(data, gameperson, mapDrawing);
data: data.data,
drawingIsActive: data.drawingIsActive,
mapdrawing: mapDrawing.identifiers[0]['mapDrawingId'],
timestamp: Date.now(),
});
await this.mapDrawHistoryRepository.insert(history);
return mapDrawing.identifiers;
return mapDrawing.identifiers;
}
}
// get ref from db
// get ref from db
@@ -46,13 +40,7 @@ export class DrawService {
@@ -46,13 +40,7 @@ export class DrawService {
});
});
if (await draw.ownershipCheck(gameperson.faction, gameperson.role)) {
if (await draw.ownershipCheck(gameperson.faction, gameperson.role)) {
// else update the existing instance
// else update the existing instance
const history = await this.mapDrawHistoryRepository.create({
await this.createHistory(data, gameperson);
data: data.data,
drawingIsActive: data.drawingIsActive,
mapdrawing: data.mapDrawingId,
timestamp: Date.now(),
});
await this.mapDrawHistoryRepository.insert(history);
return await this.mapDrawingRepository.save(drawing);
return await this.mapDrawingRepository.save(drawing);
}
}
@@ -62,6 +50,22 @@ export class DrawService {
@@ -62,6 +50,22 @@ export class DrawService {
);
);
}
}
 
// used to create mapDrawing history entity entry
 
private async createHistory(data, gameperson, mapDrawing?) {
 
// create a history entity and insert it
 
const history = await this.mapDrawHistoryRepository.create({
 
data: data.data,
 
drawingIsActive: data.drawingIsActive,
 
mapdrawing:
 
data.mapDrawingId || mapDrawing.identifiers[0]['mapDrawingId'],
 
timestamp: Date.now(),
 
});
 
history.data['faction'] = gameperson.faction
 
? gameperson.faction.factionName
 
: 'admin';
 
await this.mapDrawHistoryRepository.insert(history);
 
}
 
// draw map based on game and gameperson faction
// draw map based on game and gameperson faction
async drawMap(gameperson, gameId) {
async drawMap(gameperson, gameId) {
// return all active drawings if admin
// return all active drawings if admin
Loading