claude-sonnet-4-20250514· Anthropic LMArena Human Preference 140K
Stwórz mi system wyszukiwarki sklepów do gry metin2.
- User
Stwórz mi system wyszukiwarki sklepów do gry metin2.
- Assistant
Stworzę dla Ciebie system wyszukiwarki sklepów do Metin2. Oto kompletne rozwiązanie z interfejsem webowym:
HTML (index.html)
<!DOCTYPE html> <html lang="pl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Wyszukiwarka Sklepów - Metin2</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <header> <h1>🏪 Wyszukiwarka Sklepów Metin2</h1> </header> <div class="search-section"> <div class="search-bar"> <input type="text" id="searchInput" placeholder="Wpisz nazwę przedmiotu..."> <button onclick="searchItems()">Szukaj</button> </div> <div class="filters"> <select id="categoryFilter"> <option value="">Wszystkie kategorie</option> <option value="weapon">Broń</option> <option value="armor">Zbroja</option> <option value="accessory">Akcesoria</option> <option value="consumable">Mikstury</option> <option value="material">Materiały</option> </select> <select id="serverFilter"> <option value="">Wszystkie serwery</option> <option value="Aeldra">Aeldra</option> <option value="Nemesis">Nemesis</option> <option value="Corvinia">Corvinia</option> </select> <input type="number" id="maxPrice" placeholder="Maks. cena"> </div> </div> <div class="results-section"> <div id="resultsCount"></div> <div id="shopResults"></div> </div> <div class="add-shop-section"> <h3>Dodaj swój sklep</h3> <form id="addShopForm"> <input type="text" id="shopName" placeholder="Nazwa sklepu" required> <input type="text" id="ownerName" placeholder="Nick właściciela" required> <select id="shopServer" required> <option value="">Wybierz serwer</option> <option value="Aeldra">Aeldra</option> <option value="Nemesis">Nemesis</option> <option value="Corvinia">Corvinia</option> </select> <input type="text" id="location" placeholder="Lokalizacja (np. Map1 x:123 y:456)"> <button type="submit">Dodaj sklep</button> </form> </div> </div> <script src="script.js"></script> </body> </html>CSS (style.css)
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Arial', sans-serif; background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); color: #333; min-height: 100vh; } .container { max-width: 1200px; margin: 0 auto; padding: 20px; } header { text-align: center; margin-bottom: 30px; } header h1 { color: #fff; font-size: 2.5em; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); } .search-section { background: rgba(255,255,255,0.95); padding: 25px; border-radius: 15px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); margin-bottom: 30px; } .search-bar { display: flex; gap: 10px; margin-bottom: 20px; } .search-bar input { flex: 1; padding: 12px; border: 2px solid #ddd; border-radius: 8px; font-size: 16px; } .search-bar button { padding: 12px 25px; background: #4CAF50; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; transition: background 0.3s; } .search-bar button:hover { background: #45a049; } .filters { display: flex; gap: 15px; flex-wrap: wrap; } .filters select, .filters input { padding: 10px; border: 2px solid #ddd; border-radius: 8px; font-size: 14px; } .results-section { background: rgba(255,255,255,0.95); padding: 25px; border-radius: 15px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); margin-bottom: 30px; } #resultsCount { margin-bottom: 20px; font-weight: bold; color: #666; } .shop-card { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 10px; padding: 20px; margin-bottom: 15px; transition: transform 0.2s, box-shadow 0.2s; } .shop-card:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.1); } .shop-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; } .shop-name { font-size: 1.3em; font-weight: bold; color: #2c3e50; } .shop-server { background: #3498db; color: white; padding: 5px 12px; border-radius: 20px; font-size: 0.9em; } .shop-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 15px; } .info-item { display: flex; align-items: center; gap: 8px; } .items-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; } .item-card { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 12px; display: flex; justify-content: space-between; align-items: center; } .item-name { font-weight: bold; } .item-price { color: #e74c3c; font-weight: bold; } .add-shop-section { background: rgba(255,255,255,0.95); padding: 25px; border-radius: 15px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); } .add-shop-section h3 { margin-bottom: 20px; color: #2c3e50; } #addShopForm { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; } #addShopForm input, #addShopForm select { padding: 12px; border: 2px solid #ddd; border-radius: 8px; font-size: 14px; } #addShopForm button { grid-column: 1 / -1; padding: 12px; background: #3498db; color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; transition: background 0.3s; } #addShopForm button:hover { background: #2980b9; } @media (max-width: 768px) { .filters { flex-direction: column; } .search-bar { flex-direction: column; } .shop-header { flex-direction: column; align-items: flex-start; gap: 10px; } }JavaScript (script.js)
// Przykładowe dane sklepów let shopsData = [ { id: 1, name: "Sklep Wojownika", owner: "WarriorKing", server: "Aeldra", location: "Map1 x:234 y:567", items: [ { name: "Miecz Smoka +9", category: "weapon", price: 50000000 }, { name: "Zbroja Płytowa +7", category: "armor", price: 25000000 }, { name: "Pierścień Siły", category: "accessory", price: 15000000 } ], lastUpdate: new Date() }, { id: 2, name: "Magiczny Arsenał", owner: "MageMaster", server: "Nemesis", location: "Map2 x:123 y:890", items: [ { name: "Różdżka Ognia +8", category: "weapon", price: 40000000 }, { name: "Mikstury HP", category: "consumable", price: 50000 }, { name: "Kamień Duszy", category: "material", price: 5000000 } ], lastUpdate: new Date() }, { id: 3, name: "Sklep Łucznika", owner: "ArcherPro", server: "Corvinia", location: "Map1 x:456 y:123", items: [ { name: "Łuk Elficki +9", category: "weapon", price: 45000000 }, { name: "Naszyjnik Zręczności", category: "accessory", price: 20000000 }, { name: "Strzały Magiczne", category: "consumable", price: 100000 } ], lastUpdate: new Date() } ]; // Funkcja wyszukiwania function searchItems() { const searchTerm = document.getElementById('searchInput').value.toLowerCase(); const categoryFilter = document.getElementById('categoryFilter').value; const serverFilter = document.getElementById('serverFilter').value; const maxPrice = document.getElementById('maxPrice').value; let filteredShops = shopsData.filter(shop => { // Filtr serwera if (serverFilter && shop.server !== serverFilter) { return false; } // Sprawdź czy sklep ma przedmioty pasujące do kryteriów const matchingItems = shop.items.filter(item => { // Filtr nazwy const nameMatch = !searchTerm || item.name.toLowerCase().includes(searchTerm); // Filtr kategorii const categoryMatch = !categoryFilter || item.category === categoryFilter; // Filtr ceny const priceMatch = !maxPrice || item.price <= parseInt(maxPrice); return nameMatch && categoryMatch && priceMatch; }); return matchingItems.length > 0; }); displayResults(filteredShops, searchTerm, categoryFilter, maxPrice); } // Funkcja wyświetlania wyników function displayResults(shops, searchTerm = '', categoryFilter = '', maxPrice = '') { const resultsContainer = document.getElementById('shopResults'); const resultsCount = document.getElementById('resultsCount'); resultsCount.textContent = `Znaleziono ${shops.length} sklepów`; if (shops.length === 0) { resultsContainer.innerHTML = '<p>Nie znaleziono sklepów spełniających kryteria wyszukiwania.</p>'; return; } resultsContainer.innerHTML = shops.map(shop => { // Filtruj przedmioty zgodnie z kryteriami const filteredItems = shop.items.filter(item => { const nameMatch = !searchTerm || item.name.toLowerCase().includes(searchTerm); const categoryMatch = !categoryFilter || item.category === categoryFilter; const priceMatch = !maxPrice || item.price <= parseInt(maxPrice); return nameMatch && categoryMatch && priceMatch; }); return ` <div class="shop-card"> <div class="shop-header"> <div class="shop-name">${shop.name}</div> <div class="shop-server">${shop.server}</div> </div> <div class="shop-info"> <div class="info-item"> <span>👤</span> <span>Właściciel: ${shop.owner}</span> </div> <div class="info-item"> <span>📍</span> <span>Lokalizacja: ${shop.location}</span> </div> <div class="info-item"> <span>🕒</span> <span>Aktualizacja: ${formatDate(shop.lastUpdate)}</span> </div> </div> <div class="items-list"> ${filteredItems.map(item => ` <div class="item-card"> <div class="item-name">${item.name}</div> <div class="item-price">${formatPrice(item.price)} Yang</div> </div> `).join('')} </div> </div> `; }).join(''); } // Funkcja dodawania nowego sklepu document.getElementById('addShopForm').addEventListener('submit', function(e) { e.preventDefault(); const shopName = document.getElementById('shopName').value; const ownerName = document.getElementById('ownerName').value; const shopServer = document.getElementById('shopServer').value; const location = document.getElementById('location').value; const newShop = { id: shopsData.length + 1, name: shopName, owner: ownerName, server: shopServer, location: location || "Nie podano", items: [], // Można rozszerzyć o formularz dodawania przedmiotów lastUpdate: new Date() }; shopsData.push(newShop); // Wyczyść formularz this.reset(); // Odśwież wyniki displayResults(shopsData); alert('Sklep został dodany pomyślnie!'); }); // Funkcje pomocnicze function formatPrice(price - User
Stwórz w języku python.
- Assistant
Stworzę dla Ciebie system wyszukiwarki sklepów do Metin2 w Pythonie z interfejsem webowym używając Flask:
Struktura projektu
metin2_shop_search/ ├── app.py ├── models.py ├── database.py ├── templates/ │ ├── base.html │ ├── index.html │ └── add_shop.html ├── static/ │ ├── style.css │ └── script.js └── requirements.txtrequirements.txt
Flask==2.3.3 SQLAlchemy==2.0.21 Flask-SQLAlchemy==3.0.5 Werkzeug==2.3.7models.py
from flask_sqlalchemy import SQLAlchemy from datetime import datetime db = SQLAlchemy() class Shop(db.Model): __tablename__ = 'shops' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) owner = db.Column(db.String(50), nullable=False) server = db.Column(db.String(20), nullable=False) location = db.Column(db.String(100)) created_at = db.Column(db.DateTime, default=datetime.utcnow) updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) # Relacja z przedmiotami items = db.relationship('Item', backref='shop', lazy=True, cascade='all, delete-orphan') def to_dict(self): return { 'id': self.id, 'name': self.name, 'owner': self.owner, 'server': self.server, 'location': self.location, 'created_at': self.created_at.isoformat(), 'updated_at': self.updated_at.isoformat(), 'items': [item.to_dict() for item in self.items] } class Item(db.Model): __tablename__ = 'items' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) category = db.Column(db.String(20), nullable=False) price = db.Column(db.BigInteger, nullable=False) quantity = db.Column(db.Integer, default=1) enhancement = db.Column(db.String(10)) # np. "+9" shop_id = db.Column(db.Integer, db.ForeignKey('shops.id'), nullable=False) created_at = db.Column(db.DateTime, default=datetime.utcnow) def to_dict(self): return { 'id': self.id, 'name': self.name, 'category': self.category, 'price': self.price, 'quantity': self.quantity, 'enhancement': self.enhancement, 'shop_id': self.shop_id, 'created_at': self.created_at.isoformat() } # Kategorie przedmiotów CATEGORIES = { 'weapon': 'Broń', 'armor': 'Zbroja', 'accessory': 'Akcesoria', 'consumable': 'Mikstury', 'material': 'Materiały', 'other': 'Inne' } # Serwery SERVERS = ['Aeldra', 'Nemesis', 'Corvinia', 'Rubinum', 'Samos']database.py
from models import db, Shop, Item def init_sample_data(): """Inicjalizuje bazę danych przykładowymi danymi""" # Sprawdź czy dane już istnieją if Shop.query.first(): return # Sklep 1 shop1 = Shop( name="Sklep Wojownika", owner="WarriorKing", server="Aeldra", location="Map1 x:234 y:567" ) items1 = [ Item(name="Miecz Smoka", category="weapon", price=50000000, enhancement="+9"), Item(name="Zbroja Płytowa", category="armor", price=25000000, enhancement="+7"), Item(name="Pierścień Siły", category="accessory", price=15000000), Item(name="Naszyjnik Witalności", category="accessory", price=12000000), ] for item in items1: shop1.items.append(item) # Sklep 2 shop2 = Shop( name="Magiczny Arsenał", owner="MageMaster", server="Nemesis", location="Map2 x:123 y:890" ) items2 = [ Item(name="Różdżka Ognia", category="weapon", price=40000000, enhancement="+8"), Item(name="Mikstury HP", category="consumable", price=50000, quantity=100), Item(name="Kamień Duszy", category="material", price=5000000, quantity=10), Item(name="Szata Maga", category="armor", price=30000000, enhancement="+6"), ] for item in items2: shop2.items.append(item) # Sklep 3 shop3 = Shop( name="Sklep Łucznika", owner="ArcherPro", server="Corvinia", location="Map1 x:456 y:123" ) items3 = [ Item(name="Łuk Elficki", category="weapon", price=45000000, enhancement="+9"), Item(name="Naszyjnik Zręczności", category="accessory", price=20000000), Item(name="Strzały Magiczne", category="consumable", price=100000, quantity=500), Item(name="Skórzana Zbroja", category="armor", price=18000000, enhancement="+8"), ] for item in items3: shop3.items.append(item) # Dodaj do bazy db.session.add_all([shop1, shop2, shop3]) db.session.commit() print("Przykładowe dane zostały dodane do bazy!")app.py
from flask import Flask, render_template, request, jsonify, redirect, url_for, flash from models import db, Shop, Item, CATEGORIES, SERVERS from database import init_sample_data import os app = Flask(__name__) app.config['SECRET_KEY'] = 'your-secret-key-here' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///metin2_shops.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # Inicjalizacja bazy danych db.init_app(app) @app.before_first_request def create_tables(): db.create_all() init_sample_data() @app.route('/') def index(): return render_template('index.html', categories=CATEGORIES, servers=SERVERS) @app.route('/search') def search(): # Pobierz parametry wyszukiwania search_term = request.args.get('q', '').strip() category = request.args.get('category', '') server = request.args.get('server', '') max_price = request.args.get('max_price', '') min_price = request.args.get('min_price', '') # Rozpocznij zapytanie query = Shop.query # Filtruj po serwerze if server: query = query.filter(Shop.server == server) # Pobierz sklepy shops = query.all() # Filtruj sklepy które mają pasujące przedmioty filtered_shops = [] for shop in shops: matching_items = [] for item in shop.items: # Filtr nazwy przedmiotu name_match = not search_term or search_term.lower() in item.name.lower() # Filtr kategorii category_match = not category or item.category == category # Filtr ceny price_match = True if max_price: try: price_match = price_match and item.price <= int(max_price) except ValueError: pass if min_price: try: price_match = price_match and item.price >= int(min_price) except ValueError: pass if name_match and category_match and price_match: matching_items.append(item) if matching_items: shop_dict = shop.to_dict() shop_dict['items'] = [item.to_dict() for item in matching_items] filtered_shops.append(shop_dict) return jsonify({ 'shops': filtered_shops, 'count': len(filtered_shops) }) @app.route('/add_shop', methods=['GET', 'POST']) def add_shop(): if request.method == 'POST': try: # Pobierz dane sklepu shop_name = request.form.get('shop_name') owner_name = request.form.get('owner_name') server = request.form.get('server') location = request.form.get('location', '') # Walidacja if not all([shop_name, owner_name, server]): flash('Wszystkie pola są wymagane!', 'error') return render_template('add_shop.html', categories=CATEGORIES, servers=SERVERS) # Utwórz nowy sklep new_shop = Shop( name=shop_name, owner=owner_name, server=server, location=location ) db.session.add(new_shop) db.session.commit() flash('Sklep został dodany pomyślnie!', 'success') return redirect(url_for('add_items', shop_id=new_shop.id)) except Exception as e: db.session.rollback() flash(f'Błąd podczas dodawania sklepu: {str(e)}', 'error') return render_template('add_shop.html', categories=CATEGORIES, servers=SERVERS) @app.route('/add_items/<int:shop_id>', methods=['GET', 'POST']) def add_items(shop_id): shop = Shop.query.get_or_404(shop_id) if request.method == 'POST': try: item_name = request.form.get('item_name') category = request.form.get('category') price = request.form.get('price') quantity = request.form.get('quantity', 1) enhancement = request.form.get('enhancement', '') if not all([item_name, category, price]): flash('Nazwa, kategoria i cena są wymagane!', 'error') return render_template('add_items.html', shop=shop, categories=CATEGORIES) new_item = Item( name=item_name, category=category, price=int(price), quantity=int(quantity) if quantity else 1, enhancement=enhancement if enhancement else None, shop_id=shop_id ) db.session.add(new_item) db.session.commit() flash('Przedmiot został dodany!', 'success') except ValueError: flash('Nieprawidłowa cena lub ilość!', 'error') except Exception as e: db.session.rollback() flash(f'Błąd podczas dodawania przedmiotu: {str(e)}', 'error') return render_template('add_items.html', shop=shop, categories=CATEGORIES) @app.route('/shop/<int:shop_id>') def shop_details(shop_id): shop = Shop.query.get_or_404(shop_id) return render_template('shop_details.html', shop=shop, categories=CATEGORIES) @app.route('/api/shops') def api_shops(): """API endpoint zwracający wszystkie sklepy""" shops = Shop.query.all() return jsonify([shop.to_dict() for shop in shops]) @app.route('/api/shop/<int:shop_id>/items') def api_shop_items(shop_id): """API endpoint zwracający przedmioty z konkretnego sklepu""" shop = Shop.query.get_or_404(shop_id) return jsonify([item.to_dict() for item in shop.items]) # Filtry dla szablonów @app.template_filter('format_price') def format_price(price): """Formatuje cenę z separatorami tysięcy""" return f"{price:,}".replace(',', ' ') @app.template_filter('get_category_name') def get_category_name(category_key): """Zwraca polską nazwę kategorii""" return CATEGORIES.get(category_key, category_key) if __name__ == '__main__': app.run(debug=True, host='0.0.0.0', port=5000)templates/base.html
<!DOCTYPE html> <html lang="pl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %}Wyszukiwarka Sklepów - Metin2{% endblock %}</title> <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> </head> <body> <nav class="navbar"> <div class="nav-container"> <a href="{{ url_for('index') }}" class="nav-brand">🏪 Metin2 Shops</a> <div class="nav-links"> <a href="{{ url_for('index') }}">Wyszukaj</a> <a href="{{ url_for('add_shop') }}">Dodaj Sklep</a> </div> </div> </nav> <div class="container"> {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %} <div class="alert alert-{{ 'success' if category == 'success' else 'error' }}"> {{ message }} </div> {% endfor %} {% endif %} {% endwith %} {% block content %}{% endblock %} </div> <script src="{{ url_for('static', filename='script.js') }}"></script> </body> </html>templates/index.html
{% extends "base.html" %} {% block content %} <div class="search-section"> <h1>🔍 Wyszukiwarka Sklepów Metin2</h1> <form id="searchForm" class="search-form"> <div class="search-row"> <input type="text" id="searchInput" name="q" placeholder="Wpisz nazwę przedmiotu..." class="search-input"> <button type="submit" class="search-btn">Sz
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.