Implemented houses

This commit is contained in:
Torsten Schulz
2025-05-08 17:38:51 +02:00
parent b15d93a798
commit a9e6c82275
17 changed files with 1129 additions and 156 deletions

View File

@@ -25,6 +25,13 @@ class FalukantController {
this.acceptMarriageProposal = this.acceptMarriageProposal.bind(this);
this.getGifts = this.getGifts.bind(this);
this.sendGift = this.sendGift.bind(this);
this.getHouseTypes = this.getHouseTypes.bind(this);
this.getTitelsOfNobility = this.getTitelsOfNobility.bind(this);
this.getMoodAffect = this.getMoodAffect.bind(this);
this.getCharacterAffect = this.getCharacterAffect.bind(this);
this.getUserHouse = this.getUserHouse.bind(this);
this.getBuyableHouses = this.getBuyableHouses.bind(this);
this.buyUserHouse = this.buyUserHouse.bind(this);
}
async getUser(req, res) {
@@ -368,16 +375,17 @@ class FalukantController {
async sendGift(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { giftId} = req.body;
const result = await FalukantService.sendGift(hashedUserId, giftId);
res.status(200).json(result);
const { userid: hashedUserId } = req.headers;
const { giftId } = req.body;
const result = await FalukantService.sendGift(hashedUserId, giftId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
const status = error.status === 412 ? 412 : 500;
res.status(status).json({ error: error.message });
console.error(error);
}
}
}
async getTitelsOfNobility(req, res) {
try {
const { userid: hashedUserId } = req.headers;
@@ -399,6 +407,63 @@ class FalukantController {
console.log(error);
}
}
async getMoodAffect(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getMoodAffect(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
async getCharacterAffect(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getCharacterAffect(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
async getUserHouse(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getUserHouse(hashedUserId);
console.log(result);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
async getBuyableHouses(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const result = await FalukantService.getBuyableHouses(hashedUserId);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
async buyUserHouse(req, res) {
try {
const { userid: hashedUserId } = req.headers;
const { houseId } = req.body;
const result = await FalukantService.buyUserHouse(hashedUserId, houseId);
res.status(201).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
console.log(error);
}
}
}
export default FalukantController;