2024-02-22 15:58:22 +00:00
|
|
|
from flask import jsonify, Blueprint
|
2024-02-28 20:01:43 +00:00
|
|
|
from ..util.utils import breeding_pair_data
|
2024-02-22 03:23:13 +00:00
|
|
|
|
|
|
|
get_breeding_pairs_bp = Blueprint('breeding_pairs',__name__)
|
|
|
|
|
|
|
|
# Read the CSV file and store breeding information
|
|
|
|
breeding_info = []
|
2024-02-28 20:01:43 +00:00
|
|
|
with open(breeding_pair_data, 'r') as file:
|
2024-02-22 03:23:13 +00:00
|
|
|
lines = file.readlines()
|
|
|
|
header = lines[0].strip().split(',')
|
|
|
|
for line in lines[1:]:
|
|
|
|
data = line.strip().split(',')
|
|
|
|
breeding_info.append(dict(zip(header, data)))
|
|
|
|
|
|
|
|
def get_breeding_pairs(monster):
|
|
|
|
pairs = []
|
|
|
|
for entry in breeding_info:
|
2024-02-22 14:20:06 +00:00
|
|
|
if entry['offspring'].lower() == monster.lower():# or entry['mate'].lower() == monster.lower():
|
2024-02-22 03:23:13 +00:00
|
|
|
pairs.append({'base': entry['base'], 'mate': entry['mate'], 'offspring': entry['offspring']})
|
|
|
|
return pairs
|
|
|
|
|
2024-02-22 14:20:06 +00:00
|
|
|
@get_breeding_pairs_bp.route('/api/breeding/pairs/<monster>', methods=['GET'])
|
2024-02-22 03:23:13 +00:00
|
|
|
def breeding_pairs(monster):
|
|
|
|
pairs = get_breeding_pairs(monster)
|
|
|
|
return jsonify({'breeding_pairs': pairs})
|