import { article, sentenceCase, toLink } from "../string_utils.js";
import Model from "./model.js";
/**
* A horse. Becuase most people (myself included) don’t know horse appearance and how it’s
* described, we’re experimenting here with linking out to an image search.
*/
export default class Horse extends Model {
constructor({ name, behavior, pattern, gender, type, effect } = {}) {
super({ tags: [] });
this.name = name;
this.behavior = behavior;
this.pattern = pattern;
this.gender = gender;
this.type = type;
this.effect = effect;
}
toLink() {
// TODO: This needs to be centralized
return `https://duckduckgo.com/?t=ffab&q=${this.pattern}+${this.type}&ia=images&iax=images`;
}
#to(insertString) {
let arr = [];
arr.push(this.behavior);
arr.push(insertString);
arr.push("named");
arr.push(`${this.name}.`);
if (this.effect) {
arr.push(`${this.effect}.`);
}
return sentenceCase(article(arr.join(" ")));
}
#str() {
return `${this.pattern} ${this.type}`;
}
toHtml() {
return this.#to(`<a target="_blank" href="${toLink(this.#str())}">${this.#str()}</a>`);
}
toString() {
return this.#to(this.#str());
}
}